Dear group,
I am trying to extract 10th line from group of files.
I am able to do it with
find . -name "*.final.out" | parallel "awk 'NR ==10' {} >> result.txt"
However, I need to add a filename in the output file for every line so that I can identify from which file the line came from.
On Thursday, 26 January 2017 10:20:43 UTC-6, Kaz Kylheku wrote:
On 2017-01-26, kishorereddyanekalla@gmail.com <kishorereddyanekalla@gmail.com> wrote:
Dear group,
I am trying to extract 10th line from group of files.
I am able to do it with
find . -name "*.final.out" | parallel "awk 'NR ==10' {} >> result.txt"
However, I need to add a filename in the output file for every line so that I can identify from which file the line came from.
'NR==10 { print FILENAME, $0 }'
You are relying on these ">> result.txt" from parallel jobs being
atomic. This is only the case if each Awk job performs its output as a
single write() system call.
Got it Thanks !!!
On 2017-01-26, kishorereddyanekalla@gmail.com <kishorereddyanekalla@gmail.com> wrote:
Dear group,
I am trying to extract 10th line from group of files.
I am able to do it with
find . -name "*.final.out" | parallel "awk 'NR ==10' {} >> result.txt"
However, I need to add a filename in the output file for every line so that I can identify from which file the line came from.
'NR==10 { print FILENAME, $0 }'
You are relying on these ">> result.txt" from parallel jobs being
atomic. This is only the case if each Awk job performs its output as a
single write() system call.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 74:55:02 |
Calls: | 6,489 |
Calls today: | 2 |
Files: | 12,096 |
Messages: | 5,276,047 |