Question about Ben Busby lecture #3 on NCBI now
1
0
Entering edit mode
9.2 years ago
dawngfield • 0

Ben,

I understood all of the Linux lesson until the last slide. Or I thought I did. I have never done Linux before. I don't understand the (for I in 'awk '{print $3}' foo10'; do echo $i; done). That line and the 2 others after it make no sense to me. First why would I do it and then walking through each line what do the pieces mean? I thought you were asking to find the I in column 3.

That can't be it because Matt showed up. I don't understand the grep or the bash line either but I think if I can understand the echo line it may help.

Dawn Field

ncbi_now ncbinow • 2.0k views
ADD COMMENT
1
Entering edit mode

Hi Dawn, we have no idea what you are talking about. There is a lot of really specific information here without context. For example, who is Matt and Ben, and what slides are you referring to? You should provide some links at least so people can try to help.

ADD REPLY
0
Entering edit mode

It's a specific question - but devoid of context. I'm not sure you meant to post it here.

For this reason we have closed your question.

ADD REPLY
0
Entering edit mode

A quick reminder on the following announcement:

Questions for the NCBI Next Generation Sequencing Online Workshop Can be Posted with the NCBI_NOW Tag

This question is about the content on the NCBI Now presentations. The original poster has properly annotated the title but the content of the question itself may have seemed a bit off topic for those those that may have missed the announcement.

ADD REPLY
0
Entering edit mode

Please change the tag from ncbinow to ncbi_now.

ADD REPLY
0
Entering edit mode
9.2 years ago
Michael 55k
for i in
`awk '{print $3}' foo10`; do echo $i; done

The only thing it does is to print the 3rd column of file foo10, same could be achieved easier using cut -f3

ADD COMMENT
0
Entering edit mode

This is just an example of how to program a loop. Please note the usage of backticks around the call to awk, while the first argument of awk is enclosed in single-quotes (the above code snippet seems to be wrong). Awk is a special programming language, and the first argument comprises the code executed by the awk interpreter. 'echo' is a function which prints its arguments to the standard output channel.

ADD REPLY
1
Entering edit mode

I think there are too many things going on in that script to begin with.

It has both a bash construct and an awk construct. There is really no reason to do both at a beginner level.

ADD REPLY
0
Entering edit mode

I wouldn't trust any of the original quotes due to encoding or typos.

The following should work:

echo -e "bla blubb foo bar\nbs bc foo lol" > foo10
for i in `awk '{print $3}' foo10`; do echo $i; done

If it's just to demonstrate how a loop works it's not such a good example because of additional complication.

for i in `cut -d" " -f 3 foo10`; do echo $i; done
for i in 1 2 3 ; do echo $i; done

Might be easier to grasp.

ADD REPLY

Login before adding your answer.

Traffic: 1903 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6