Need Command-line help

Discussion in 'Community Discussion' started by EricBrian, Feb 20, 2013.

  1. EricBrian macrumors 6502a

    EricBrian

    Joined:
    Jul 30, 2005
    #1
    How to find all *.py files that have the word "404" and "split" in them starting in the "Documents" folder?

    Thanks for any help.
     
  2. mobilehaathi macrumors G3

    mobilehaathi

    Joined:
    Aug 19, 2008
    Location:
    The Anthropocene
    #2
    Code:
    for file in `find ~/Documents -type f -name "*.py"`
    do 
        if [ -n "`cat $file | grep split`" -a -n "`cat $file | grep 404`" ] 
        then
    	echo $file;
        fi
    done
    
    Might not be the most efficient, but it ought to work.
     

Share This Page