CS155: Introduction to Unix

Fall 2017

Commands 3

See this page as a slide show

More Commands

CS155 Commands3

sed – stream editor

sed syntax

All lines:sed 'command' filename
One line:sed 'line command' filename
Range of lines:sed 'startline,endline command' filename


sed line specification

A line specification in sed can be:

sed: A Few Examples

sed: A Few Examples

sed: More Examples

A Little More Regular Expression Syntax

Alternation through Escaping

diff: Comparing Files

file1 file2

hello world.
this is file1.
it's a lame file.
the end.

hello world.
this is file2.
it's a sweet file.
the end.
maybe not.

diff: Comparing Files

% diff file1 file2
< this is file1.
< it's a lame file.
> this is file2.
> it's a sweet file.
> maybe not.

file: Getting Information on File Type

% file Honda.pdf
Honda.pdf: PDF document, version 1.4
% file AdobeFnt.lst
AdobeFnt.lst: PostScript document text
% file Xrootenv.0
Xrootenv.0: ASCII text, with very long lines
% file school/cs553.tgz
school/cs553.tgz: gzip compressed data, from Unix
% file /bin/bash
/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, stripped

Modified: 2016-09-12T12:55

User: Guest

Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building