I have the following shell script
#!/bin/sh
keyExists=`stat ~/.ssh/id_rsa &> /dev/null; echo $?`
echo $keyExists
When I run it as ./test.sh or sh test.sh it outputs
0 File: `/home/vagrant/.ssh/id_rsa' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fc00h/64512d Inode: 2888560 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000/ vagrant) Gid: ( 1000/ vagrant) Access: 2014-07-23 11:40:33.355848310 -0400 Modify: 2014-07-23 11:40:33.355848310 -0400 Change: 2014-07-23 11:40:33.355848310 -0400 Birth: -
However when I run each command individually on the command line
keyExists=`stat ~/.ssh/id_rsa &> /dev/null; echo $?`
echo $keyExists
I get the output
0
Why am I seeing this additional output and how do I suppress this additional output when I run the shell script?
/bin/shrunsshinstead ofbash, or if it'sbash, turns offbash4enhancements?&>is functional only inbash4 and later.&>is available in earlier versions ofbashas well.