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 > 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 and shell scripting languages 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 07:44 PM
Matching string nehaquick UNIX for Dummies Questions & Answers 7 02-19-2008 11:51 AM
sed problem - replacement string should be same length as matching string. amangeles Shell Programming and Scripting 4 01-11-2006 06:11 AM
SED: Matching a string with whitespace? cstovall Shell Programming and Scripting 1 06-07-2005 03:32 PM
matching alphanumeric string sskb Shell Programming and Scripting 4 12-12-2001 10:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-28-2006
mpang_ mpang_ is offline
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!
  #2 (permalink)  
Old 07-28-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,420
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 06:06 AM..
  #3 (permalink)  
Old 07-28-2006
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

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

Join Date: Mar 2006
Posts: 89
thanks you guys! you guys ROCK!
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 04:51 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