regex - Using sed and grep to search and replace -
I am using egrep -R
followed by a regular expression with 10 unions Is like: .jpg | .png | .gif
etc. It works well, now I want to change all the strings found with .bmp
I think like something
For example - lR "\ .jpg | \ .png. \ .gif". | That is why this issue is how do I make regular uniforms in sed
and how should I tell it? To save changes to this file, from which input is found.
Use this command:
Example-L-R R jade "\ .jpg | \ .png. \ .gif" \ | Xargs-0 -l sed -i -e s /. Jpg \. \ .gif \. \ .png / .bmp / g '
-
<
egrep
: using extended regular expressions Find matching line-
-l
: matches only file names -
-R
: Search again through all the given directories -
-Z
:as the record separator \ 0
to use -
".jpg | \ .png. \ .gif"
:".jpg "
," .gif "
or.png"
.
: Start searching in the current directory
-
-
xargs
: Execute an order with a stdin as argument-
-0
: Use the\ 0
to record separator It is important to match- z
withegrep
and to avoid being fooled by spaces and new lines in the input filenames. -
-l
: Use a line per command as a parameter
-
-
sed
: s from ed itor-
-i
: replace -
-e
: Use the following logic as expression -
'/' Jpg \. \ .gif \. \ .png / .bmp / g '
: Replace all the events in the wires".jpg"
,".gif"
or".png"
with".bmp"
-
Comments
Post a Comment