Linux Shell Scripting Tutorial (LSST) v1.05r3 | ||
Chapter 7: awk Revisited | ||
|
Using sed you can delete all blank line from file as follow
$ sed '/^$/d' demofile1
As you know pattern /^$/, match blank line and d, command deletes the blank line.
Following sed command takes input from who command and sed is used to check whether particular user is logged or not.
$ who | sed -n '/vivek/p'
Here -n option to sed command, suppress the output of sed command; and /vivek/ is the pattern that we are looking for, finally if the pattern found its printed using p command of sed.
sed - Quick Introduction | How to write sed scripts? |