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?

Example:

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


6tr6tr

6tr6tr’s Profile: http://forums.opensuse.org/member.php?userid=12994
View this thread: http://forums.opensuse.org/showthread.php?t=403560

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

Code:

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

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: http://forums.opensuse.org/member.php?userid=180
View this thread: http://forums.opensuse.org/showthread.php?t=403560

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

Code:

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…

Code:

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


rmjones101

rmjones101’s Profile: http://forums.opensuse.org/member.php?userid=15486
View this thread: http://forums.opensuse.org/showthread.php?t=403560