Skip to content

Instantly share code, notes, and snippets.

@frntn
Created May 6, 2014 17:23
Show Gist options
  • Save frntn/392fa57c970a65d56d13 to your computer and use it in GitHub Desktop.
Save frntn/392fa57c970a65d56d13 to your computer and use it in GitHub Desktop.
Proof of Concept : Pipe (and color output for proof) of stderr only
#!/bin/bash
function outerr {
echo "this is on standard ouput (blank color)"
echo "but this one is on error ouput (red color)" >&2
}
exec 3>&1
outerr 2>&1 >&3 | sed -e 's/^/'$(printf "\033[1;31m")'/' -e 's/$/'$(printf "\033[39m")'/'
exec 3>&-
: <<SUCCESSFULLY_TESTED_ON
bash$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
bash$ uname -a
Linux precise32 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux
SUCCESSFULLY_TESTED_ON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment