bash cripting function to "identify" any char in a string?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
bash cripting function to "identify" any char in a string?
hi.. I'm traying to make a script that automate this cc command to compile:
cc -o theFile theFile.c
The script should recieve the name of the .c file as it only argument, and creates the binary named as the .c file WHITOUT the .c extension.
To do so, I need to "read" the content of the $1 variable, and be able to "identify" its period and take the first half of the variable's name, and put it on a new variable which will be the name of the binary file.
The fact is I founded how to add a extension to a variable: $1{.bak}
..but not how to take it off from it.
Does anybody know if it is possible using bash scripting?
and if so: which commands should I use to "meassure" and "truncate" a variable?
examples are welcome
regards,
hey, thanks 4 the answers! *really* fast!!
Booster: about the 'make' cmd.. I use to use it for the classic configure/make/make-install procedure to compile progs.. but here, when I give to it just one .c file as parameter (textually as you post), nothing is done .. I recreate the output:
Code:
~$ make myProg.c
make: No se hace nada para `myProg.c'
...and now.. ..translated:
Code:
make: nothing is done to `myProg.c'
-of course, 'make' doesn't create any binary file. It seems it's waitin' 4 something else to do it job.. I also do the 'make --help', but didn't found the -cyb --CompileYouBast#%&! option
...
About the scripts: gonna try'em out right now, and see which one fit better to my needs..
thanks again to all of you, pals!
Booster: about the 'make' cmd.. I use to use it for the classic configure/make/make-install procedure to compile progs.. but here, when I give to it just one .c file as parameter (textually as you post), nothing is done .. I recreate the output:
try "make myProg"
ie without the ".c"
I just tried (to be sure), and:
Code:
paul@pc vid [0]$ vi test.c
paul@pc vid [0]$ make test
cc test.c -o test
paul@pc vid [0]$
yeps, Booster.. that's the way .. without extension..
Steve: just tried out your recipe, and it works just fine, too
I'm amazing about the many ways to perform such a "trivial" task like this
tx again, and happy coding!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.