A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

October 29, 2013

using find command for multiple files and then manipulating the results

Hello. I am new here. I have Linux experience but it is fairly limited. I have been trying to find a solution to the following problem:

I have a directory that contains multiple files. First, I need to find all files with an extension of ".trg" I have successfully done this using the find command:

param=`find *${file_name}*.trg`

this provides me with two filenames in the param variable:

ABC1099C.trg ABC1099R.trg

I need to take the text prior to the .trg (so ABC1099 from the first occurrence) and then find the associated filename with a .dat extension.

I tried using string operators but was unsuccessful. Maybe I should be using some kind of array processing?

Ideas?

Any help would be greatly appreciated.

THANKS

Click Here!