awk record separator question
Hi.
given a data file 'test' such as: Code:
test1a test1b test1c but Code:
awk -v FS='\n' '{print $1}' test Code:
test1a test1b test1c Code:
awk -v FS='\n' '{print $2}' test I thought by setting the FS to newline, that test1a test1b test1c would become the first field, test2a test2b test2c the second. and so on... therefore I would expect Code:
awk -v FS='\n' '{print $1}' test Code:
test1a test1b test1c Would appreciate if someone could point me in the right direction. |
Your understanding of the difference between 'field' and 'record' seems to be part of the problem.
Each line is a record, made up of three fields, seperated by a space. So, you need to print each line (record) of the file. |
Thanks for the reply...
I'm doing this inside a bash while loop. Each record (entire line) is filtered through awk which will write the line to a temporary file...the values in this temporary file will then be passed to a separate program for calculations and so on... I need awk to output each record as a single field for this purpose...so the problem remains Code:
#!/bin/bash |
All times are GMT -5. The time now is 02:21 PM. |