sed

sed

 

Acpi

Adduser.conf

Adjtime

Aliases

Aliases.db

Alsa

Alternatives

Anacrontab

 

 

Print Command

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.

bash.bashrc

bash_completion

bash_completion.d

 

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.

 

acpi

adduser.conf

adjtime

aliases

aliases.db

alsa

alternatives

anacrontab

apm

apt

at.deny

bash.bashrc

bash_completion

bash_completion.d

bogofilter.cf

bonobo-activation

calendar

 

 

 

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.

 

Bash.bashrc

Bash_completion

Bash_completion.d