ls *.txt | lp
I was told that this command above wouldn't do anything but start an empty print queue
if so then wouldn't the command
cat *.txt | lp
print all files that end in .txt right?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
DESCRIPTION lp submits files for printing or alters a pending job. Use a filename of "-" to force printing from the standard input.
So depending on your print system you might get different results from
cat *.txt | lp -
The former lp looks at each file individually (and knows the name for it). In the latter the output of all those files is made into one and then lp treats it as one unnamed file.
Some print systems do a cover page per thing submitted - so you can see how it might be different with "N" things vs 1.
ls *.txt and
cat *.txt is not the same at all.
ls *.txt will list all the files in the current directory with the extension ".txt".
cat *.txt try to find a file "*.txt" from the current directory and print the file content on standard output.
ls *.txt > ouput_file lp output_file