I may be missing something small, but is it possible to achieve this syntax in a POSIX (dash) compliant way:
$ ./myApp 2> stderr.txt 1> stdout.txt
I know in dash you cannot use >&
but have to use 2>&1
but I do not want to do this. I have tons of data coming to stdout and I do not want to parse it to get my stderr. I feel like I am missing something extremely simple but I cannot put my finger on it...
Right now when I run the above command, I get only a few lines of my stdout (3) but it shows up in the stderr file and stdout is empty. I have also tried various ways of grouping it but still I have had no luck. Not sure what is going on...
UPDATE
This is the format of the actual command I am running so that you can see the full effect of what I am trying to accomplish:
$ LD_PRELOAD=/usr/lib/libtcmalloc.so /usr/bin/time -p myApp -c -f inputFile 2> stderr 1> stdout
This is where I mentioned that I tried multiple variants of groupings with (). Also, the executable myApp
does not fork.
I thought that this command would work, but I have found otherwise:
$ LD_PRELOAD=/usr/lib/libtcmalloc.so /usr/bin/time -p (myApp -c -f inputFile) 2> stderr 1> stdout
Posting since I answered in the comments:
The syntax you posted is the correct syntax, but you may be getting some interference from the output of the time
command. Try
time -p sh -c 'LD_PRELOAD=/usr/lib/libtcmalloc.so command >stdout.txt 2>stderr.txt'