10.2. Calling sed

You can invoke sed in three ways: by typing the commands on the command line; by inserting sed commands in a script file then calling sed; or by inserting sed commands in a script file and making the script executable.

To use sed from the command line for one-liners use:

sed [options] 'sed-commands' input-file(s) 

Remember when using sed commands on the command line to surround the actual commands with single quotes, although sed will tolerate double quotes.

To use a sed script file use this format:

sed [ options] -f sed-script-file input-file(s) 

To use a sed script file that has the sed command interpreter line as the first line of the script file use this format:

sed-script-file [options] input-file(s) 

Whether you are running ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.