diff options
Diffstat (limited to '.cheat/sed')
| -rwxr-xr-x | .cheat/sed | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/.cheat/sed b/.cheat/sed new file mode 100755 index 0000000..e22c97a --- /dev/null +++ b/.cheat/sed @@ -0,0 +1,17 @@ +# To replace all occurrences of "day" with "night" and write to stdout: +sed 's/day/night/g' file.txt + +# To replace all occurrences of "day" with "night" within file.txt: +sed -i 's/day/night/g' file.txt + +# To replace all occurrences of "day" with "night" on stdin: +echo 'It is daytime' | sed 's/day/night/g' + +# To remove leading spaces +sed -i -r 's/^\s+//g' file.txt + +# To remove empty lines and print results to stdout: +sed '/^$/d' file.txt + +# To replace newlines in multiple lines +sed ':a;N;$!ba;s/\n//g' file.txt |
