Click to See Complete Forum and Search --> : Is there a cli search/replace...?


StarWeaver
11-25-2000, 07:17 AM
This is one of those little things about linux... you can't find out something until you already know it. Is there a standard CLI search and replace tool where i could do something like:

cat mp3list.m3u | replace "\" "/" | replace "e:" "/drv/seiryuu" > mp3list.linux

? ... It really seams like it should exist ... it seems like it should be a part of grep but it's not. (already used that to filter all lines with # :)

Thanks
-RASX

speck
11-25-2000, 12:24 PM
Check into "man sed". This should work on the "\" "/" problem:
sed -e 's/\//\\/g' mp3list.m3u > mp3list_new.m3u

The second looks like:
sed -e 's/e:/\/drv\/seiryuu/g' mp3list_new.m3u > mp3list.m3u

If you notice, I run the sed command twice. First writing it to a temp _new file and the second one writes it back to the original name. More for instruction than efficiency.

Speck

Strike
11-25-2000, 02:50 PM
man tr
http://www.linuxnewbie.org/ubb/smile.gif

StarWeaver
11-25-2000, 02:59 PM
Thanks, i'll look into that. those. I fixed it last night just by using gnp... :) sed looks a little complicated but so does anything with lots of //\/\\/\ stuff.

-RASX -my only problem is FINDING the right tool... sometimes it seems like youre in a huge tool shed and each tool is in a bland cardboard box and all you want is a hammer or screw... :)-