Pick the specific format file in the folder
I want pick the specific format of file among the list of files in a directory from linux. 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 |
Welcome.
It looks like you are dealing with the file names and not the format they contain. You should be able to work out a pattern based on similarities and then use ls to show you the name of the files that match the pattern. See "man 7 glob" for the basics of that. What have you tried so far and where are you stuck? |
You want only the files without SUM in the name?
Or only last field? Probably both? Which program do you think is needed? OK |
Yes AnanthaP,
I want the files with out SUM in the name.. |
The exact format of the file isn't apparent. Does each line have 3 fields?
Anyway the pseudo code is: For each line --- For each field --- If it doesn't start with SET and doesn't contain SUM, then pick it for further action. Now think about what packages (sed, awk, grep ..) you would use and how you would go about it. OK |
GNU's ls can exclude patterns using the -I option, too.
|
If using bash shell, enabling extglob would allow extended matching patterns like
Code:
shopt -s extglob |
All times are GMT -5. The time now is 02:40 PM. |