Skip to content

Instantly share code, notes, and snippets.

@iyedb
Last active August 29, 2015 13: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 iyedb/9358027 to your computer and use it in GitHub Desktop.
Save iyedb/9358027 to your computer and use it in GitHub Desktop.
A small bash script to compile and execute one file C++ programs
#!/bin/bash
#./ce.sh filename.cxx|cpp args...
CC="c++ -std=c++11 -o"
src_name=$1
exe_name=${src_name%.c[px]*}
if [ -f "$exe_name" ]
then
echo "delete $exe_name"
rm "$exe_name"
fi
compile_line="$CC $exe_name $1"
echo "compiling: $compile_line"
$compile_line
if [ $? -eq 0 ]
then
echo "compiling OK"
shift
echo "$exe_name output:"
echo
./$exe_name $@
fi
@iyedb
Copy link
Author

iyedb commented Mar 4, 2014

./ce.sh filename.cxx|cpp args...
(ce = compile execute)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment