cp -a `ls | grep -v yourexcludepattern` ../destinationdir/
Assume, you want to copy all files, except *.java within from the current directory to the foo directory. Then, the command would be,
cp -a `ls | grep -v *.java` /home/wageesha/foo
cp -a `ls | grep -v yourexcludepattern` ../destinationdir/
cp -a `ls | grep -v *.java` /home/wageesha/foo
for dir in *; do [ -d "$dir" ] && cp file.txt "$dir" ; done
for dir in *; do [ -d "$dir" ] && cp -rf /home/wageesha/images "$dir" ; done
find . -iname "*.xml" | xargs grep -l "<br>" | xargs sed -i -e 's/[<]br[>]/<br\/>/g'
find . -iname "*.xml" | xargs grep -l "<br>" | xargs sed -i -e 's/foo/bar/g'A more general form of the expression would be
find . \( -name "*.php" -or -name "*.html" \) | xargs grep -l 'TEXT TO SEARCH' | xargs sed -i -e 's/TEXT TO REPLACE/REPLACEMENT STRING/g'
find . | xargs rename 's/\.xml$/\.html/i'Using exec
find . -exec rename 's/\.xml$/\.html/i' {} +Above commands recurrsively replace files within inner directories too. If you want to do it for current directory only you can use -prune.
find . -prune | xargs rename 's/\.xml$/\.html/i'
find . -prune -exec rename 's/\.xml$/\.html/i' {} +
find /home -name "test.txt" -printSearch all the .txt files in /home directory, use
find /home -name "*.txt" -printif you want to search for a string through all the files .txt files, there are two ways
find /home -name "*.txt" -exec grep -q "string-to-be-searched" '{}' \; -print
find /home -name "*.txt" | xargs grep "string-to-be-searched"second one is more fast and efficient. Removal of -q in the first command will output the text segment where the specified string is. If you want to search all files for the string, just remove -name "*txt" option.