tags:

views:

116

answers:

3

I'm using a few commands to cat a few files, like this:

 cat somefile | grep example | awk -F '"' '{ print $2 }' | xargs cat

It nearly works, but my issue is that I'd like to add a newline after each file.

Can this be done in a one liner?

(surely I can create a new script or a function that does cat and then echo -n but I was wondering if this could be solved in another way)

+2  A: 
cat somefile | grep example | awk -F '"' '{ print $2 }' | while read file; do cat $file; echo ""; done
Randy Proctor
@Randy Proctor: excellent :) (I can only accept the answer in 7 minutes, will keep the tab open :)
NoozNooz42
A: 

awk -F '"' '/example/{ system("cat " $2 };printf "\n"}' somefile

frankc
A: 

Using GNU Parallel http://www.gnu.org/software/parallel/ it may be even faster (depending on your system):

cat somefile | grep example | awk -F '"' '{ print $2 }' | parallel "cat {}; echo"
Ole Tange