The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #15 (permalink)  
Old 10-24-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Here is an approach with awk


Code:
> ls -w1
./
../
LG_JG_CLIENT_20081024114245_1.txt
LG_JG_CLIENT_200810241142_1.txt
LG_JG_CLIENT_baddata.txt
LG_JG_CUSTOMER_20081024114245.txt
LG_JG_CUSTOMER_20081024114245_1.txt
LM_CM_CUSTOMER_20081024114245_2.txt
LM_CM_TELEPHONE_20081024114245_1.txt
LM_CM_TELEPHONE_20081024114245_2.txt
LM_CM_TELEPHONE_20081024114269_3.txt
LM_JG_CUSTOMER_20081024114245_1.txt

> ls | awk -F"_" 'NF==5 && ($3=="CLIENT" || $3=="CUSTOMER") {print $0}'
LG_JG_CLIENT_20081024114245_1.txt
LG_JG_CLIENT_200810241142_1.txt
LG_JG_CUSTOMER_20081024114245_1.txt
LM_CM_CUSTOMER_20081024114245_2.txt
LM_JG_CUSTOMER_20081024114245_1.txt

> ls | awk -F"_" 'NF==5 && ($3=="CLIENT" || $3=="CUSTOMER") && ($4>20080101000000) {print $0}'
LG_JG_CLIENT_20081024114245_1.txt
LG_JG_CUSTOMER_20081024114245_1.txt
LM_CM_CUSTOMER_20081024114245_2.txt
LM_JG_CUSTOMER_20081024114245_1.txt

Perhaps you can see/understand the logic used here, and expand upon it for your needs.
I make sure five fields -- four _ characters
I see if field 3 is CLIENT or CUSTOMER
I verify that the date > 2080101 (date) 000000 (time)