The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
null string matching in sed? Allasso Shell Programming and Scripting 6 05-30-2008 04:44 PM
Matching string nehaquick UNIX for Dummies Questions & Answers 7 02-19-2008 08:51 AM
sed problem - replacement string should be same length as matching string. amangeles Shell Programming and Scripting 4 01-11-2006 03:11 AM
SED: Matching a string with whitespace? cstovall Shell Programming and Scripting 1 06-07-2005 12:32 PM
matching alphanumeric string sskb Shell Programming and Scripting 4 12-12-2001 07:48 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-28-2006
Registered User
 

Join Date: Mar 2006
Posts: 89
String matching

for a certain directory, I want to grep a particular file called ABCD so what I do is

ls /my/dir | grep -i "ABCD" | awk '{print $9}'

however, there is also this file called ABCDEFG, the above command would reurn both file when I only want ABCD, please help!
Reply With Quote
Forum Sponsor
  #2  
Old 07-28-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
Move the sed logic in awk :
Code:
ls -l /my/dir | awk 'toupper($9)=="ABCD" {print $9}'
Jean-Pierre.

Last edited by aigles; 07-28-2006 at 03:06 AM.
Reply With Quote
  #3  
Old 07-28-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Or:
Quote:
Originally Posted by mpang_
ll /my/dir | grep -i "ABCD$" | awk '{print $9}'
Regards
Reply With Quote
  #4  
Old 07-28-2006
Registered User
 

Join Date: Mar 2006
Posts: 89
thanks you guys! you guys ROCK!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0