0

I have several files: one_001_three.txt, one_002_three.txt, . . .

After removing the extension, I would like to call it such that:

    ${fname}_001

would call the file 'one_001'

Any ideas?

2
  • Can you clarify your requirement better, it is not clear what you want. Commented Apr 10, 2014 at 14:16
  • fname=one; echo "${fname}_001" produces one_001... Or perhaps you want something more like x=one_001_three.txt; fname=${x%%_*}? It's really not clear... Commented Apr 10, 2014 at 15:58

2 Answers 2

2

As far as i understood your Question ..

yu can use this command basename try with this and develop .

basename one_001_three.txt _three.txt -->this will give output as one_001 .

the filename doesnt get changed though .

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for not being clear, this is all I needed. Thanks.
0

As far as i understood your Question ..

you can use this command basename try with this and develop .

basename one_001_three.txt _three.txt -->this will give output as one_001 .

the filename doesnt get changed though

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.