New answers tagged

2

Your sed command only sends its result to the standard output. You would have to redirect it in a subsequent command (NOT in the same command, like sed 'sedcommand' file > file, as this would erase the file before processing it). You also can pipe the commands to ed instead of using sed : for file in $filelist ; do echo -e ...


6

Try this: sed 's/yyyymmdd/YYYYMMDDHH24MISS/g' filename > changed.txt Or, to keep the same filename: sed 's/yyyymmdd/YYYYMMDDHH24MISS/g' filename > changed.txt && mv changed.txt filename


0

Did a little tweak to purplepsycho solution for i in {1..152} do sed -i.bak -e "s/[[i]]/[[$i]]]/g" plot_vents_$i done Thanks!


1

In bash: for i in {1...152} do sed -i.bak -e "s/[[i]]/[[$i]]/g plot_$i done This script will run sed on each file, and backup them before replacing the string.


0

If you prefer a GUI tool, you can try jEdit. It has excellent search and replace functionality, including folder (directory) search. You can use regular expressions if you like. Hypersearch pops up a separate window with the results.


1

I'm absolutely new to emacs but I can suggest the following: M-b to move backward over a word M-d to kill up to the end of the word Now you can write a new word. Works almost like cw in vim


2

Even though sed is commonly used for these types of tasks, it isn't actually designed for them—its very name is stream editor. The tool that is designed for non-interactive file editing is ex. (vi is the "visual editor" form of ex.) Particularly when you want to edit files in place, ex is a far superior tool to sed. In this case the commands used are ...


4

sed will work, but this is much simpler with tr, which translates characters. for file in *.php; do tr 'ăâîșțĂÂÎȘȚ' 'aaistaaist' < "${file}" > "translated_${file}" The sed equivalent (which you'll need on GNU systems, not OS/X where tr doesn't support multibyte characters) would be: sed 'y/ăâîșțĂÂÎȘȚ/aaistaaist/'


1

You can replace the characters using the formula sed s/old_string/new_string/. From manpage: sed - stream editor for filtering and transforming text s/regexp/replacement/ Attempt to match regexp against the pattern space. If successful, replace that portion matched with replacement. The replacement may contain the ...



Top 50 recent answers are included