1

I need to compile all of the C files in a directory into seperate outputs... see example gcc -Wall program1.c -o program1.out

How do I do this?

2
  • You'd need to at least tell us which operating system and shell you're using.
    – slhck
    Jul 7, 2014 at 5:50
  • Bash. I only need to do this once, I used to have a script and I remember it had some regex to make test.c.out into test.out
    – user341814
    Jul 7, 2014 at 5:52

1 Answer 1

3

Use string manipulation:

for f in *.c; do gcc -Wall "$f" -o "${f%%.c}.out"; done

No need for complicated regular expressions or anything that's not a shell builtin here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .