I want pick the specific format of file among the list of files in a directory. Please find the below example.

I have a below list of files (6 files).

Set-1 1) MAG_L_NT_AA_SUM_2017_01_20.dat 2) MAG_L_NT_AA_2017_01_20.dat

Set-2 1) MAG_L_NT_BB_SUM_2017_01_20.dat 2) MAG_L_NT_BB_2017_01_20.dat

Set-3 1) MAG_L_NT_CC_SUM_2017_01_20.dat 2) MAG_L_NT_CC_2017_01_20.dat

From the above three sets I need only 3 files. 1) MAG_L_NT_AA_2017_01_20.dat 2) MAG_L_NT_BB_2017_01_20.dat 3) MAG_L_NT_CC_2017_01_20.dat

Note: There can be multiple lines of commands because i have create the script for above req. Thanks


You just need type find . -regex 'MAG_L_NT_\w\w_2017_01_20.dat' in shell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.