1834744 Members
2848 Online
110070 Solutions
New Discussion

Filename check

 
SOLVED
Go to solution
Pando
Regular Advisor

Filename check

I have a filename which is named as:

X-XX-1234-5678.xml

I used the following command to extract or list the 5678 value only.

Var=$(awk -F "-" '{print $4}')

but it list the 5678.xml

Maximum points points to all correct replies.

Many thanks in advance!

3 REPLIES 3
Biswajit Tripathy
Honored Contributor
Solution

Re: Filename check

Var=$(awk -F "-" '{print $4}' | sed 's/\.xml$//g')

- Biswajit
:-)
Biswajit Tripathy
Honored Contributor

Re: Filename check

Better still

Var=$(awk -F '[-.]' '{print $4}')

- Biswajit
:-)
Pando
Regular Advisor

Re: Filename check

Many thanks!