LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   to extract all the part of the filename before a particular word in the file (https://www.linuxquestions.org/questions/linux-newbie-8/to-extract-all-the-part-of-the-filename-before-a-particular-word-in-the-file-4175424218/)

aealexanderraj 08-27-2012 09:49 AM

to extract all the part of the filename before a particular word in the file
 
Hi All,
Thanks in Advance

I am working on a shell script. I need some assistance.

My Requirement:

1) There are some set of files in a directory like given below


OTP_UFSC_20120530000000_acc.csv
OTP_UFSC_20120530000000_faf.csv
OTP_UFSC_20120530000000_prom.csv
OTP_UFSC_20120530000000_subs.csv

I want to check if all thes files exists in the directory

the keywords are acc.csv, faf.csv, prom.csv, subs.csv
apart from this all the other things vary time to time (like the field seperator used in the file (can be.,-,_ etc) and the names OTP UFSC will vary.

2) if the file does not exist I have to touch (Create a empty file by that name)
Example : Imagine the file OTP_UFSC_20120530000000_acc.csv doesnot exist
in the directory
I have to search first if a file *acc.csv exist in the directory or not. If not i will extract the prefix (anything before acc.csv in this case OTP_UFSC_20120530000000_) from an existing file which is common to all the files in the directory
and create a file OTP_UFSC_20120530000000_acc.csv

:)
Any suggestions and help

unSpawn 08-27-2012 11:07 AM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate of http://www.linuxquestions.org/questi...le-4175424231/. Ignorance, as defined by not reading the LQ Rules, is no excuse for posting multiple duplicate threads.


All times are GMT -5. The time now is 07:53 AM.