Skip to content

Instantly share code, notes, and snippets.

@mumoshu
Created February 28, 2014 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mumoshu/9266579 to your computer and use it in GitHub Desktop.
Save mumoshu/9266579 to your computer and use it in GitHub Desktop.
Test which sed is installed on your system
testfile="/tmp/$(basename $0).$$.tmp"
echo test > $testfile
out=$(sed -e "s/^//" -i "" $testfile 2>&1)
sed_exit_status=$?
$(echo $out | grep "sed: can't read : No such fil or directory")
grep_exit_status=$?
echo $grep_exit_status
if [ $sed_exit_status -ne 0 ]; then
echo GNU sed
elif [ $grep_exit_status -ne 0 ]; then
echo BSD sed
else
echo Unknown type of sed. It\'s output is: $out
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment