Hi all,
I want to write a /bin/sh script to compile my c-programs. But I have a problem with /bin/sh:
For example:
Before I used :
Result:
But it's not easy. If I want to remove $m2 variable - I need to rewrite the index in $m3, ... $mN.
Okay, now I have variable: use="name1 name2 name3 ... nameN"..
*For example: use="mstring.c mmath.c mlib.c marr.c"
And variable $wheremylib - has full path name to my lib.
I need to concatenate all elements with variable $use with variable $wheremylib.
This can be done using the SH? Help me, please.
I want to write a /bin/sh script to compile my c-programs. But I have a problem with /bin/sh:
For example:
Code:
#!/bin/sh
wheremylib='/usr/home/iam/work' # here is my lib.
use="file1.c file2.c file3.c" # files that need to compile too.
# Really I should be use next style:
# cc -o mypo mypo.c /usr/home/iam/work/file1.c /usr/home/iam/work/file2.c
/usr/home/iam/work/file3.c -I/usr/home/iam/work/
# *** in here I must write code, to parse $use variable and make it so:
# use == '/usr/home/iam/work/file1.c /usr/home/iam/work/file2.c /usr/home/iam/work/file3.c '
# ***
cc -o mypo mypo.c $use -I$wheremylib
Before I used :
Code:
#!/bin/sh
....
wheremylib='/usr/home/iam/work'
m1='file1.c'
m2='file2.c'
m3='file3.c'
use=''; i=3
while [ $i -ge '0' ]; do
use="$use $wheremylib/\$m$i"
i=`expr $i - 1`
done
eval echo $use
...
/usr/home/iam/work/file1.c /usr/home/iam/work/file2.c /usr/home/iam/work/file3.c
But it's not easy. If I want to remove $m2 variable - I need to rewrite the index in $m3, ... $mN.
Okay, now I have variable: use="name1 name2 name3 ... nameN"..
*For example: use="mstring.c mmath.c mlib.c marr.c"
And variable $wheremylib - has full path name to my lib.
I need to concatenate all elements with variable $use with variable $wheremylib.
This can be done using the SH? Help me, please.