The UNIX and Linux Forums  

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
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 11:14 PM
Unix shell script (grep -A 6 -B 2 "ORA-" filename el_guero Shell Programming and Scripting 7 04-25-2007 06:37 PM
Pls correct the "if" syntax ganapati Shell Programming and Scripting 5 07-31-2006 03:07 AM
correct use of "ps -ef | grep "? mulligm UNIX for Dummies Questions & Answers 1 10-03-2001 09:41 PM

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 06-13-2005
yongho yongho is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 95
correct syntax for using "grep regex filename" ?

I'm trying to grep a long ls by looking at the beginning of each filename for example:

Many files begin with yong_ho_free_2005...
Many files begin with yong_ho_2005...

I can't just use "grep yong_ho" otherwise It'll display both files.
So I'm trying to use a regex but my syntax is wrong.

ls -al | grep '^yong_ho_[1-9]'

This displays no matches.
Anyone know what I'm doing wrong?

It works if I remove the ^ carat...
How come I can't anchor it?

Last edited by yongho; 06-13-2005 at 03:32 PM..
  #2 (permalink)  
Old 06-13-2005
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
The problem is that no line starts with yong, when using the long listing the file name is the last field on the far right... Dont use the ^ in your listing it is irrelevant.


ls -al | xargs| grep 'yong_ho_[1-9]'
  #3 (permalink)  
Old 06-13-2005
yongho yongho is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 95
ack!

damn... I completely forgot...
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 05:57 AM.


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