Home > OS >  one liner command to find files and print specific line
one liner command to find files and print specific line

Time:10-13

I would like to run a find command to get file list, then run sed command to show specific line content on screen. it can be done by below bash script.

flst=`find . -name zipfile.py`
for f in $flst; do
    sed -n '756p' $f
done

How can I use one liner command to implement the same in bash command line?

CodePudding user response:

You can remove newlines and specific ones replace by ;.

flst=`find . -name zipfile.py` ; for f in $flst; do sed -n '756p' $f ; done

CodePudding user response:

As Gene suggested, I have tested this command, it works:

find . -name zipfile.py -exec sed -n '756p' {} \;
  •  Tags:  
  • bash
  • Related