find . -name "*.php" -print | xargs sed -i 's/foo/bar/g'
Showing posts with label find. Show all posts
Showing posts with label find. Show all posts
Monday, 21 February 2011
Directory wide search replace
Change foo to bar for all php files.
Tuesday, 1 February 2011
I know this file is in my filesystem somewhere
$ locate xorg.conf
/\ this will find your xorg.conf and will run quicker than find from root
Monday, 20 December 2010
Searching in files
Search for files containing the string "lookfor"
find . -type f -exec grep -i "lookfor" {} \; -print
Sunday, 29 August 2010
Recursive find files and ...
Find all files of type CR2 and then delete them.
Note: The -print0 and -0 these options force the commands to use null terminators instead of spaces therefore you can remove files with spaces in the name.
Need to apply CHMOD command to only files that have a specific name recursively
Xargs to the rescue!
Note: The -print0 and -0 these options force the commands to use null terminators instead of spaces therefore you can remove files with spaces in the name.
find . -name *.CR2 -print0 | xargs -0 rm
Need to apply CHMOD command to only files that have a specific name recursively
Xargs to the rescue!
find -name fish.txt | xargs chmod 755
Clean all pyc files recursively:
find . -name "*.pyc" -exec rm -rf {} \;
Thursday, 19 August 2010
Finding a single file in multiple jar files
this script copied from:
http://www.devdaily.com/blog/post/java/shell-script-search-search-multiple-jar-files-class-pattern
http://www.devdaily.com/blog/post/java/shell-script-search-search-multiple-jar-files-class-pattern
#!/bin/sh
LOOK_FOR="codehaus/xfire/spring"
for i in `find . -name "*jar"`
do
echo "Looking in $i ..."
jar tvf $i | grep $LOOK_FOR > /dev/null
if [ $? == 0 ]
then
echo "==> Found \"$LOOK_FOR\" in $i"
fi
done
Subscribe to:
Posts (Atom)