gcc目录下所有文件

Bash综合应用gcc目录下所有文件

Use gcc to compile all C source file toobject file in one dir.

#!/bin/bash

 

for i in *.c

do

echo "$i"

echo `basename $i`

echo `basename $i .c`

gcc $i -o `basename $i .c`

done

 

Three echos are used to test how to handlefilename.

Basename command can get the file name inthe full path, and the second parameter “.c” is cutted suffix from the filename.

 

Touch three C files, and add main code inthem.

The print out will like this.

[nick@d01 compilec]$ ./compile.sh

1.c

1.c

1

2.c

2.c

2

3.c

3.c

3

 

你可能感兴趣的:(c,command,gcc,File,bash,Path)