Question

I'm trying to make bash script that's a little bit too hard for me. I need to search in directory for specific text files ending in "FA", sort the results alphabetically and take line 13 of each one and paste it into a new text file.

I read around and this is what I managed so far. This command will search and sort the results:

find . -iname "*FA" -exec ls {} \; | sort

and it works fine.

This command will search and take line 13 of each file and paste it in a new file named "FACC.txt":

find . -iname "*FA" -exec sed -n 13p >FACC.txt {} \;

and it also works fine.

Now I need to combine the two, that is sort the results and take line 13 of each one!

Thank you! Any help appreciated!

Was it helpful?

Solution

Like this?

find . -iname "*FA" -exec ls {} \; | sort | xargs -n 1 sed -n 13p
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top