Hi Mr./Ms. Anekalla,

On Thu, 26 Jan 2017 08:23:59 -0600
Kishore Reddy <[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.
> 

This is an awk question rather than a GNU parallel one. You can do the
following in GNU awk:

        awk 'FNR == 10 {print FILENAME ":" $0;nextfile;}'

FNR and FILENAME appear to be part of the standard:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html

I had to look the exact syntax up on DuckDuckGo.

Hope that helps,

        Shlomi


> Any help is appreciated.
> 
> 
> warm regards,
> Kishore R. Anekalla



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/facts/Summer-Glau/

People who think they know everything greatly annoy those of us who do.
    — Source unknown, via Linux’s fortune-mod

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Reply via email to