Tag Info

New answers tagged

0

How about a regular expression: sed -r -i 's/(data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAAkCAAAAABUcSvnAAAHbklEQVRo3u2Ya0xURxTHR9Yt6CJdLSU0hFoxPhIS41ujDex).*(HHAAAAAElFTkSuQmCC)/.\/logo.jpg/g' filename Look for the beginning and the end of the string and replace with .\/logo.jpg in filename. Use -i to replace the content in the filename.


0

with awk command awk '{gsub(/^0$/,"-1e+10");print}' file Replace all lines with -1e+10 if starts(^) and only contain 0.


1

using awk: awk '{if($0==0){print "-1e+10"}else{print $0}}' file output: 141.519 141.009 140.121 135.519 -1e+10 -1e+10 -1e+10 -1e+10 In the above code if line only contain 0 it will replace with -1e+10 else print the line as original simply: suggested by muru awk '$0 == 0 {$0 = "-1e+10"}1' file


3

Your code is missing else echo "$a". You don't have to use a loop, though: Use sed which processes the file line by line: sed -i~ -e 's/^0$/-1e+10/' $name.putch.f0.ascii -i~ creates a backup with the ~ extension. s/// means "substitute". ^ matches a line start, $ matches a line end.


1

find . -type f | xargs sed -i 's/abc/xyz/g' Use -maxdepth option if you don't want the action to take place recursively in your current working directory.



Top 50 recent answers are included