Hi,
I am trying to write a code in which i want to read the command line arguement ( which i can get by using $(0,1,...) ) and want to give the arguement to some filename.

Eg. ./myprogram filename.cpp

I want to remove ".cpp" from the filename and want to save only "filename" in separate variable, lets say $FIRSTARGV.

echo $1
$FILEARGV = ??
echo $FILEARGV // expected "filename"

./myprogram filename.cpp

output:-
filename

Thanks
Umesh

hi,

shell variable replacements can do this

$ var="filename.cpp" #note there are no spaces around the equal sign
$ echo "${var%.*}" #always quote variable replacements
filename

see your shell's man page

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.