Consider the following bash constructs:
ls /usr/include/asm > list-redir.txt
ls /usr/include/asm | tee list-tee.txt
In this case, list-redir.txt and list-tee.txt will be identical, and will contain the listing of files as expected; e.g.
$ head -5 list-redir.txt
a.out.h
auxvec.h
bitsperlong.h
boot.h
bootparam.h [...]
My question is - how could I write such a command, and have the command line text inserted as the first thing in the standard output - such that the file eventually starts with the command line as first? As an example, the file list-redir.txt would in that case look like:
$ head -5 list-redir.txt
# ls /usr/include/asm
a.out.h
auxvec.h
bitsperlong.h
boot.h [...]
... which also implies that the character # can be prepended to the inserted command line.
Is there anything that I could use for this - but with the minimum of change in typing out in respect to the original command lines (ls /usr/include/asm > list-redir.txt ...)?
