linux - How can I echo the status of compilation? -
i've written small command compile every c file in every directory, have:
find $1 -type f -name '*.c' -exec sh -c 'gcc {} -o $(dirname {})/$(basename {} .c)' \;
and compiles everything, display status of each file being compiled, , display when each 1 finished, i'm out if ideas.
if love that!
this academic issue, using {}
multiple times in argument find
not portable. similarly, expecting {}
expand filename when not string in argument not portable. (that is, entire argument must {}
). also, using gcc
explicitly rather make
wrong approach. said, can echo each path compiles:
find $1 -type f -name '*.c' -exec sh -c 'gcc $0 -o $(dirname $0)/$(basename $0.c) && echo $0' {} \;
also, if can simplify bash:
find $1 -type f -name '*.c' -exec bash -c 'gcc $0 -o ${0%.c}.o && echo $0' {} \;
Comments
Post a Comment