- Linux Training
- Desktop Tutorials
- Server Tutorials
|Linux Commands - Managing Files and Text|
The print command which is very common with sed is indicated by the letter p.
Here is a simple print command.
sed -n '/^bash/p' data
This command prints all of the lines that begin with the text string bash.
sed -n '/^a/,/^c/p' data
This sed command prints all of the lines that start with a to c and are between and c. Note that with this command it will print the first line that starts with c as well.
Multiple Edit Commands
sed allows you to use a number of commands or edits in one line by including the -e option.
sed -e 's/^bash/Bash/' -n -e '/^Bash/p' data
sed will filter the outcome to change all lines that begin with bash to Bash and then print only the lines that begin with Bash.