Linux - How to call lines from a file in a for loop???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lel7lel7
    New Member
    • Mar 2010
    • 12

    Linux - How to call lines from a file in a for loop???

    Hi,

    I am new to Linux and am trying to pull several lines from one file to modify them.

    I have written a file table.txt...

    Code:
    [lg45@dev64-mgmt ~]$ cat table.txt
    
    Angiogenin 10 25793633 25815393
    Alpha-actinin 28 7893500 7941168
    I want to pull out column 3 of each line and loop through them all adding 500,000bp.

    I know that i can use awk to call...

    Code:
    [lg45@dev64-mgmt ~]$ awk '{print$3'} table.txt
    I am looking for suggestions on how i can modify the following to add an awk statement that pulls out each column but still allows me to loop?

    Code:
    [lg45@dev64-mgmt ~]$ for i in `cat table.txt`; do echo $i; done
    Thanks :)
    lesley
  • shabinesh
    New Member
    • Jan 2007
    • 61

    #2
    Code:
    while read line
    do
      /*your code*/
    done < table.txt

    Comment

    • Hydaral
      New Member
      • Jun 2010
      • 24

      #3
      I don't quite understand what you want to accomplish, do you want to add 500000 to the number in the third column, or append the string "500,000bp" to it?

      Perhaps you could give an example of the expected output.

      If you just want to operate on the third column, then you don't need any loops.

      Comment

      Working...