If I have a file called "filename" and run sed '' filename, the contents of "filename" appear on the screen. Why is that?
sed streams file but modifies it on the fly using these programs/expressions you usually provide. If you provide empty program, no change happens and the file is printed to the screen verbatim.
the SCRIPT/COMMANDS would be within ' and ' but just an empty '' tells sed to print INPUTFILE to screen verbatim and that is because "print" is the default when nothing else is specified or when "print" is not specifically excluded from being default by use of -n.Code:sed OPTIONS SCRIPT/COMMANDS INPUTFILE
Would my understanding be correct?
Technically the script/commands part doesn't have to be within '' or "", all you have to make sure is that shell passes that part as a single parameter. Quotes are merely the most convenient way to do that but you can escape all chars related to shell syntax eg whitespace, semicolons etc.
Code:$ sed -n p\;s/\ /=/g\;p <( echo a b c ) a b c a=b=c