How use reg expr to find substring up to indexOf string?

I have a bunch of files named “xxxx.idl”. I need to pull out the
filename without the extension via regualr expression (in the above
example, that would be “xxxx”). How do I do this?


File: “SomeFile.idl”
Result of Reg Expr: “SomeFile”


6tr6tr’s Profile:
View this thread:

Must it be a reg expr or is that just another way to say what you want
as output?


cd <dir-where-they-are>
for FILE in *.idl
do echo “${FILE%.idl}”

There is no reg exp in this solution, just file name expansion and
parameter value cutoff, so you may not be happy with this.

Henk van Velden

hcvv’s Profile:
View this thread:

If you just need it for a script, you can simply…


ls *.idl | awk -F. ‘{print $1}’

That will list all files ending in .idl, then awk will output the first
field using the period ‘.’ as the field separator. From there you can
redirect the output wherever you wish. ie… to a file named ‘outputfile’
would be…


ls *.idl | awk -F. ‘{print $1}’ > outputfile


rmjones101’s Profile:
View this thread: