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
check for a particular character inside a file and substitute with a given character? karthikprasathk AIX 1 07-01-2008 04:29 AM
How ro handle backslash character in grep? rajbal Shell Programming and Scripting 1 06-18-2007 09:19 PM
Non-ascii character detection (perl or grep) srinivasan_85 UNIX for Dummies Questions & Answers 9 02-20-2007 08:38 AM
Grep for X character on a word jjoves UNIX for Dummies Questions & Answers 5 08-06-2004 06:14 AM
GREP a string with NULL Character weerich UNIX for Dummies Questions & Answers 3 09-18-2001 02:30 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 07-08-2008
Rajat Rajat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
grep with wilcard character(*)

Hello people,
I am trying to grep out a certain pattern from some files. The situation is like this:
constantstring1<random data>constantstring2
I am using the following command (which clearly is not working!!!):
datestring=<some date in YYYYMMDD format>
searchstring=$datestring"*_xyz"
grep -hc $searchstring a.txt

Can you also be kind enough to give a short explanation for the solution?
Thanks a lot.
  #2 (permalink)  
Old 07-08-2008
zaxxon's Avatar
zaxxon zaxxon is online now Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,302
You have to put a dot in front of the wildcard.
. means any character, but only one,
* means the former character zero times or multiple occurence
Ie. it's ".*" not "*".

Best have the pattern in grep in " " too and the variable written like ${myvar} to avoid problems.
  #3 (permalink)  
Old 07-08-2008
Rajat Rajat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Thanks a lot man!!!
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 09:47 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