Created
May 2, 2014 18:10
-
-
Save hhatfield/ad80d39fef702417442e to your computer and use it in GitHub Desktop.
Bash redirector with command name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
outfile=${*: -1:1} | |
remove=1 | |
echo "$@" > $outfile; "${@:1:$(($#-remove))}" >> $outfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tmp $ ./redirector.sh ls -la lsout | |
tmp $ cat lsout | |
ls -la lsout | |
total 224 | |
drwxrwxrwt 10 root wheel 340 May 2 12:09 . | |
drwxr-xr-x@ 6 root wheel 204 Oct 31 2013 .. | |
drwx------ 3 hhatfield wheel 102 May 1 08:13 launch-KrJQJV | |
drwx------ 3 hhatfield wheel 102 May 1 08:13 launch-yqQeEs | |
drwx------ 3 hhatfield wheel 102 May 1 08:13 launchd-241.qFHX6O | |
drwx------ 3 _spotlight wheel 102 May 1 08:14 launchd-612.NE2bhp | |
drwx------ 3 root wheel 102 May 1 08:14 launchd-632.do4N0n | |
-rw-r--r-- 1 hhatfield wheel 13 May 2 12:09 lsout | |
-rw-rw-rw- 1 hhatfield wheel 103000 May 2 08:49 oobelib.log | |
-rwxr-xr-x 1 hhatfield wheel 98 May 2 10:49 redirector.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment