sed
is a handy UNIX tool that manipulates a stream of text. Here I'll list some useful examples of sed
commands. This is just a note to myself. I'll add more as I learn more about sed
To replace every instance of ABC with DEF in a text file, run the following command:
sed 's/ABC/DEF/g' input.txt > output.txt
To convert DOS/WINDOWS style text to UNIX/LINUX style text, run the following command. In other words, this command removes carriage returns from the end of every line:
sed 's/\r$//g' input.txt > output.txt
To remove a tab from the beginning of every line, run:
sed 's/^\t//g' input.txt > output.txt
No comments:
Post a Comment