36 reputation
16
bio website
location Zagreb, Croatia
age
visits member for 1 year, 11 months
seen Mar 3 '13 at 9:55

Unix Administrator for telecom company


Sep
24
awarded  Autobiographer
Aug
20
awarded  Notable Question
Apr
19
awarded  Popular Question
Nov
17
comment How to traverse a file and extract words using their index?
I updated my initial question with the specific scenario.
Nov
17
revised How to traverse a file and extract words using their index?
added 867 characters in body
Nov
16
comment How to traverse a file and extract words using their index?
We are talking about an 'ls' of a large directory that produces a mutli column output that is saved to a file.
Nov
16
revised How to traverse a file and extract words using their index?
added 70 characters in body
Nov
16
comment How to traverse a file and extract words using their index?
Sorry for being unclear. The file consists of seperate lines and on each line there are words seperated by spaces or tabs. I added example input file text in my first question.
Nov
16
awarded  Commentator
Nov
16
comment How to traverse a file and extract words using their index?
The input is a multiline (but not always multiline) text file containing words seperated by spaces, tabs, new lines, etc ... (like an entire book) I need to extract each word using an index in variable form and save that word in a variable to be processed.
Nov
16
comment How to traverse a file and extract words using their index?
If I pass it a file (cat file | awk -v RS=\ 'NR==2{print}') that has 3 lines: "one two" , "three four" , "five six" it prints out "two" and then "three" on seperate lines.
Nov
16
comment How to traverse a file and extract words using their index?
No. I get the same result. Thanks.
Nov
16
comment How to traverse a file and extract words using their index?
I run the command exactly as in your example using read or read -r and prints line by line: _word1 word2_
Nov
16
comment How to traverse a file and extract words using their index?
I said file when I meant line. It is still printing line by line. "one two"
Nov
16
comment How to traverse a file and extract words using their index?
This is very good. Is there a way to send an index to awk to specify which word to print out?
Nov
16
comment How to traverse a file and extract words using their index?
I create three seperate lines with two words in each line.
Nov
16
comment How to traverse a file and extract words using their index?
Yes string=word. I tried your example however it did not work. I echo $word and it prints the entire file.
Nov
16
comment How to traverse a file and extract words using their index?
The idea is to process every string in the file as though the file were an array, without processing lines.
Nov
16
revised How to traverse a file and extract words using their index?
deleted 8 characters in body
Nov
16
awarded  Editor