On 2017-01-26, Kishore Reddy <
[email protected]> wrote:
On Thursday, 26 January 2017 10:20:43 UTC-6, Kaz Kylheku wrote:
On 2017-01-26, [email protected] <[email protected]> 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 !!!
P.S. If that parallel logging issue is a real problem, a non-useless use
of cat can help:
( echo this; awk ' ... { print that }' ) | cat >> file
Even the command issues multiple writes (as the above example will for sure, duen to different commands being used), cat will accumulate them up and issue
a single write when its stdin closes --- that is, if you don't go over
cat's I/O buffer size, which is almost certainly generous enough for a
small piece of output.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)