Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get filename without extension 2

Status
Not open for further replies.

philipose

Programmer
Dec 24, 2003
137
US
Unix gurus,
I am using the K Shell and trying to create a shell script. I need to get a filename without an extension. ie if $file contains value "xyz.log", i need the value "xyz". i would use $file:r in C Shell, but that is not working here. Any suggestions

Thanks in advance
philipose
 
Check out the man page for basename

- Rod


IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 
For what you want:
Code:
${file%.*}

Other examples:
Code:
file=xyz.abc.log
${file%%.*} = xyz
${file%.*+ = xyz.abc
${file##*.} = log
${file#.*} = abc.log
 
Guys,
you are awesome. works like a dream. star to both.
philipose
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top