Hi

I know the cut option which is used to cut the column from file. I like to get the filename only when it is being stored in the variable with the extension attached to.

file=jasmine.txt

I like to fetch jasmine(file name only). I am newbie to shell scripting. Please help me.

Jasmine

If there will always be only one "." as in filename.txt then given
var=filename.txt
you can do
var2=`echo $var | awk -F'.' '{print $1}'`

if there is any possibility that the filename will have more than one "." as in filename.date.txt
then given
var=filename.date.txt
you can do
var2=`echo $var | sed -e 's/\.[^\.]*$//'`
this will return filename.date

Thank u very much.It is working fine.

I used this one var2=`echo $var | awk -F. '{print $1}'`

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.