Sed — Stream Editor
Print Lines From a File
Print entire file:
$ cat file.txt (1) $ sed '' file.tx (2) $ sed -n p file.txt (3) $ sed -n '1,$ p' file.txt (3)
-
Yeah, we could use
cat
. -
Or use an empty command, which by default (without
-n
) just outputs the content of the pattern space. -
Or using
-n
to avoid auto-printing of the pattern space and explicitly usingp
command to print, which prints all the lines if no address is used. -
Doing everything explicitly.
GNU sed -i option
$ sed -i 's/^ /\t/' < Makefile sed: no input files
Of course, the -i
option takes a file, not STDIN.
We got STDIN instead of the Makefile
because we used redirection.