Need script Script

Hi Need a shell script that pulls out me the required list of files from the specific locations.

First it has to go the below location and get the list of files from all the sub folders (Where * are having multiple folders in it)

/ct-data/prod/dockets/*/statedocket/*/fullfile

Then from the list of files it has to give me only the files having the name NEW.080415 in it.

Later from the files given with having name NEW.080415 i'm fine tuning with the below command

grep -E 'NEW.080315.00*|NEW.080315.01*|NEW.080315.02*|NEW.080315.03*|NEW.080315.04*|NEW.080315.05*'

Could some one help me to write a script for this.

Does your grep version have the -r option?

no.

The below are the commands i using to get the exact result.

---------- Post updated at 05:36 AM ---------- Previous update was at 05:36 AM ----------

ls -ltr /ct-data/prod/dockets/*/statedocket/*/fullfile | grep 'NEW.080415' > test1 

more test1 | cut -c57- > test2 grep -E 'NEW.080315.00*|NEW.080315.01*|NEW.080315.02*|NEW.080315.03*|NEW.080315.04*|NEW.080315.05*' test2 | more 

mail -s "Result" testing2019@gmail.com < test2

Where and how is that failing (except for the redirection of cut 's results to test2, where you should use tee )?

In my commands i'm getting the results in two different files and from that im getting the out put.

instead i need a script which send email directly to me. Currently i'm using commands instead i need it as a script. i'm a beginner.

Try (untested):

ls -ltr /ct-data/prod/dockets/*/statedocket/*/fullfile | grep 'NEW.080415'| cut -c57-  | grep -E  'NEW.080315.0[0-5]*' | mail -s "Result" testing2019@gmail.com

I'm not sure that after grep ping for "NEW.080415" there will be any results for "NEW.080315", though...

My script as follows

#!/bin/bash
clear
echo -e '\n'"Which state you are looiking for"
read Y
find /ct-data/prod/dockets/*/$Y/*/fullfile -name "*NEW.080515*" 

The result:

/ct-data/prod/dockets/source/statedocket/n_dcalosangel/fullfile/N_DCALOSANGEL.daily.NEW.080515.000128.merged.xml.gz
/ct-data/prod/dockets/source/statedocket/n_dcalosangel/fullfile/N_DCALOSANGEL.daily.NEW.080515.030518.merged.xml.gz
/ct-data/prod/dockets/source/statedocket/n_dcalosangel/fullfile/N_DCALOSANGEL.daily.NEW.080515.050611.merged.xml.gz

Time frame'000128' is there followed by date'080515'. From the result, the script should get only the file names having time frame between 000001-050000 (12am - 5 am)

The last line of your result should not be printed as it's 6 min 11 sec later than your specified 5 am limit.

Try

find /path -name "*NEW.080315.0[0-4]*" -o -name "*NEW.080315.050000"

I think there is a missing asterisk there:

find /path -name "*NEW.080315.0[0-4]*" -o -name "*NEW.080315.050000*"
1 Like