2013-08-23 19:00:37 -04:00
|
|
|
# To replace all occurrences of "day" with "night" and write to stdout:
|
2013-08-21 00:17:52 -04:00
|
|
|
sed 's/day/night/g' file.txt
|
2013-08-11 15:37:11 -04:00
|
|
|
|
2013-08-23 19:00:37 -04:00
|
|
|
# To replace all occurrences of "day" with "night" within file.txt:
|
2013-08-21 00:17:52 -04:00
|
|
|
sed -i 's/day/night/g' file.txt
|
2013-08-11 15:37:11 -04:00
|
|
|
|
2013-08-23 19:00:37 -04:00
|
|
|
# To replace all occurrences of "day" with "night" on stdin:
|
2013-08-21 00:17:52 -04:00
|
|
|
echo 'It is daytime' | sed 's/day/night/g'
|
2013-08-27 00:06:30 +03:00
|
|
|
|
|
|
|
# To remove leading spaces
|
|
|
|
sed -i -r 's/^\s+//g' file.txt
|
2013-08-31 12:46:33 +03:00
|
|
|
|
|
|
|
# To remove empty lines
|
|
|
|
cat file.txt | sed '/^$/d'
|