Results 1 to 2 of 2
I want to set a number of files of the same type (.ext) equal to the variable FILES without the file extension part of the filename (or then remove the ...
- 05-12-2008 #1Just Joined!
- Join Date
- Jul 2007
- Location
- San Francisco, CA
- Posts
- 7
Stripping the extension name (file.ext) from files (set, foreach commands)
I want to set a number of files of the same type (.ext) equal to the variable FILES without the file extension part of the filename (or then remove the file extensions)...
e.g.
$ls
file1.ext file2.ext file3.ext
$set FILES=`ls *.ext`
foreach FILE ($FILES) #now, here FILES = file1, file2, file3 (without file extension)
Is this possible or is there another way of doing it?
thanks.
- 05-12-2008 #2Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Don't use ls unless there's no alternative.
For example:
Read more about the bash string mangling capabilities on the internet, for example:Code:for file in /path/to/*.ext do i=${file%.*} echo "$i" done
Variable Mangling in Bash with String Operators


Reply With Quote
