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