How to make sed read its script from a file?

Viewed 37766

Recently I came across following grep command:

/usr/xpg4/bin/grep -Ff grep.txt input.txt > output.txt

which as per my understanding means that from input.txt, grep the matter contained in grep.txt and output it to output.txt.

I want to do something similar for sed i.e. I want to keep the sed commands in a separate file (say sed.txt) and want to apply them on input file (say input.txt) and create a output file (say output.txt).

I tried following:

/usr/xpg4/bin/sed -f sed.txt input.txt > output.txt

It does not work and I get the following error:

sed: command garbled

The contents of files mentioned above are as below:

sed.txt

sed s/234/acn/ input.txt
sed s/78gt/hit/ input.txt

input.txt

234GH
5234BTW
89er
678tfg
234
234YT
tfg456
wert
78gt
gh23444
2 Answers
Related