Under Linux replace batch file content method
HTTPS: // www.cnblogs.com/fjping0606/p/4428850.html command used to write the original author just fine record it for future use.
1: Find
the Find The -type f -name "* .html" | xargs grep 'yourstring'.
2: find and replace
find -name 'To find the name of the file' | xargs perl -pi -e 's | character to be replaced string | replacement string | G '
perl -pi -e
. with the -e option, followed by a line of code in Perl command, then it will run the code that runs like a normal Perl script
from the command line Perl can help achieve some powerful, real-time conversion. Careful study of the regular expression, and the right to use, will save a lot of manual editing work for you.
3: Bulk folder permissions to modify
the Find The -type -d -name * .html | xargs chmod 755.
4: batch edit file permissions
. Find -type -f -name * .html | xargs chmod 644
Find and Replace is a very common operating.
Little tips presented here allows you to easily complete a lot of repetition, tedious work.
Examples explained to
the search string "password" in .c files in the current directory
grep "password" * .c
looks in the current directory and its subdirectories multiple files test.c
the Find -name "test.c." - print
Find .vbs file in the current directory and its subdirectories and delete multiple of
find -name "* .vbs" -exec rm {} \.;
Find .c files in the current directory and its subdirectories multiple string "password"
the Find -name "* .c" -print |. Xargs grep "password"
in .c files in the current directory in the string " password "replaced" pwd "
Perl -pi -e 'S / password / pwd / G' * .c
in .c files in the current directory in the string" password "replace" pwd "and .bak extension backup
perl -pi.bak -e 's / password / pwd / g' * .c
replacement string "password" .c files in the current directory and subdirectories as "pwd"
Find. -name "* .c "-print | xargs perl -pi -e ' s / password / pwd / g'
are used interchangeably sed batch operation
format: sed -i" s / lookup field / replacement fields / g "` grep lookup field -rl path `
Linux sed batch files of the plurality of replacement string
sed -i "s / oldstring / newstring / g" `grep oldstring -rl yourdir`
example: the replacement / home to all the files in www.viiving.com www.zjant.com
Sed -i "s / www.viiving.com / www.zjant.com / g "` grep www.viiving.com -rl / mysites
operate in the current directory: sed -i "s / www.viiving.com / www.zjant.com / g" *
1: Find
the Find The -type f -name "* .html" | xargs grep 'yourstring'.
2: find and replace
find -name 'To find the name of the file' | xargs perl -pi -e 's | character to be replaced string | replacement string | G '
perl -pi -e
. with the -e option, followed by a line of code in Perl command, then it will run the code that runs like a normal Perl script
from the command line Perl can help achieve some powerful, real-time conversion. Careful study of the regular expression, and the right to use, will save a lot of manual editing work for you.
3: Bulk folder permissions to modify
the Find The -type -d -name * .html | xargs chmod 755.
4: batch edit file permissions
. Find -type -f -name * .html | xargs chmod 644
Find and Replace is a very common operating.
Little tips presented here allows you to easily complete a lot of repetition, tedious work.
Examples explained to
the search string "password" in .c files in the current directory
grep "password" * .c
looks in the current directory and its subdirectories multiple files test.c
the Find -name "test.c." - print
Find .vbs file in the current directory and its subdirectories and delete multiple of
find -name "* .vbs" -exec rm {} \.;
Find .c files in the current directory and its subdirectories multiple string "password"
the Find -name "* .c" -print |. Xargs grep "password"
in .c files in the current directory in the string " password "replaced" pwd "
Perl -pi -e 'S / password / pwd / G' * .c
in .c files in the current directory in the string" password "replace" pwd "and .bak extension backup
perl -pi.bak -e 's / password / pwd / g' * .c
replacement string "password" .c files in the current directory and subdirectories as "pwd"
Find. -name "* .c "-print | xargs perl -pi -e ' s / password / pwd / g'
are used interchangeably sed batch operation
format: sed -i" s / lookup field / replacement fields / g "` grep lookup field -rl path `
Linux sed batch files of the plurality of replacement string
sed -i "s / oldstring / newstring / g" `grep oldstring -rl yourdir`
example: the replacement / home to all the files in www.viiving.com www.zjant.com
Sed -i "s / www.viiving.com / www.zjant.com / g "` grep www.viiving.com -rl / mysites
operate in the current directory: sed -i "s / www.viiving.com / www.zjant.com / g" *