The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list the files but exclude the files in subdirectories shyjuezy UNIX for Dummies Questions & Answers 8 10-15-2008 01:42 PM
How to copy specified files from list of files from dir A to dir B pmeesara Shell Programming and Scripting 3 09-29-2008 03:40 PM
How list of files apart from *.class files in certain folder itsjoy2u Shell Programming and Scripting 3 09-04-2008 10:28 AM
scp list of files nmahendran Shell Programming and Scripting 1 09-03-2008 08:09 AM
counting a list of string in a list of txt files Pep Puigvert UNIX for Dummies Questions & Answers 4 08-15-2008 03:55 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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)
  #16 (permalink)  
Old 10-24-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
Thanks , I've got it:
Quote:
set -o vi
> Version M-11/16/88f

  #17 (permalink)  
Old 10-24-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
Thanks joeyg!!!
  #18 (permalink)  
Old 10-24-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
HI joeyg,

Quote:
> ls -l | grep "[A-Z]*_[A-Z]*_[A-Z]*_[0-9]\{14\}*_[0-9]*.txt"
What is this in here?: _[0-9]\{14\}*_
  #19 (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

Quote:
What is this in here?: _[0-9]\{14\}*_
Checking for _ then numerical digits, 14 to be precise.
If 13 or 15, then not selected.
  #20 (permalink)  
Old 10-24-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Great parallel thread

+ file globbing
+ how to find the version of ksh
  #21 (permalink)  
Old 10-24-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
It is Friday, eow, have no more brain energy...

Is there way to use something like IN condition within awk
Quote:
> ls | awk -F"_" 'NF==5 && ($3=="CLIENT" || $3=="CUSTOMER") && ($4>20080101000000) {print $0}'
something like:

Quote:
> ls | awk -F"_" 'NF==5 && ($3 in "$object_list") && ($4>20080101000000) {print $0}'
Thanks and have a great weekend!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0