Is there any difference between (# comments taken from documentation)
command > filename # Docs: Redirect stdout to a file.
command 1> filename # Docs: Redirect stdout to file "filename."
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
From the Bash manual's section on Redirection (emphasis mine):
Redirection of output causes the file whose name results from the expansion of word to be opened for writing on file descriptor n, or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created; if it does exist it is truncated to zero size.
So, there is no difference between
Standard output is the implicit file descriptor if it isn't listed, so they're effectively the same thing. Using
1> is not a style that I've ever seen.
% grep _FILENO /usr/include/unistd.h #define STDIN_FILENO 0 /* standard input file descriptor */ #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */