Created
November 18, 2014 18:31
-
-
Save bhyde/a51273d161ac08515dff to your computer and use it in GitHub Desktop.
A clever scheme to indent shell output, which doesn't work :(
This file contains 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 | |
function indent(){ | |
exec 6>&1 | |
exec > >(sed 's/^/ /') | |
} | |
function end_indent(){ | |
exec 1>&6 6>&- | |
} | |
echo one | |
indent | |
echo two | |
end_indent | |
echo three |
This file contains 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
one | |
three | |
two |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment