Answer the question
In order to leave comments, you need to log in
Why is the sed script not executing?
In the book of William Shotts, there is such an example. File containing OS names, versions, and release dates (output shortened to save space). File distr.txt (tab delimiter):
SUSE 10.2 12/07/2006
Fedora 10 11/25/2008
SUSE 11.0 06/19/2008
Ubuntu 8.04 04/24/2008
sed 's/\([0-9]\{2\}\)\/\([0-9]\{2\}\)\/\([0-9]\{4\}\)$/\3-\1-\2/' distr.txt
SUSE 10.2 2006-07-12
Fedora 10 2008-25-11
SUSE 11.0 2008-19-06
Ubuntu 8.04 2008-24-04
1 i\
\
Linux Distributions Report\
s/\([0-9]\{2\}\)\/\([0-9]\{2\}\)\/\([0-9]\{4\}\)$/\3-\1-\2/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
sed -f distr.sed distr.txt
Linux Distributions Report
SUSE 10.2 2006-12-07
FEDORA 10 2008-11-25
SUSE 11.0 2008-06-19
UBUNTU 8.04 2008-04-24
Linux Distributions Report
s/([0-9]{2})/([0-9]{2})/([0-9]{4})$/3-1-2/
SUSE 10.2 12/07/2006
FEDORA 10 11/25/2008
SUSE 11.0 06/19/2008
UBUNTU 8.04 04/24/2008
Answer the question
In order to leave comments, you need to log in
You have an extra backslash ( \
) afterReport
$ cat distr.sed
1 i\
\
Linux Distributions Report
s/\([0-9]\{2\}\)\/\([0-9]\{2\}\)\/\([0-9]\{4\}\)$/\3-\1-\2/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
$ sed -f distr.sed distr.txt
Linux Distributions Report
SUSE 10.2 2006-12-07
FEDORA 10 2008-11-25
SUSE 11.0 2008-06-19
UBUNTU 8.04 2008-04-24
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question