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
Find cmd not working as expected Vishal123 Shell Programming and Scripting 6 08-29-2007 02:11 AM
how to find in which shell i am working.. pineapple Shell Programming and Scripting 2 04-01-2007 10:56 PM
FIND/GREP problem dfb500 UNIX for Dummies Questions & Answers 1 11-13-2006 11:13 AM
find/if statement not working geomonap Shell Programming and Scripting 12 12-16-2005 09:56 AM
How to find our working compiler s_aamir Shell Programming and Scripting 8 04-04-2002 04:08 AM

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
  #1 (permalink)  
Old 05-07-2008
kittusri9 kittusri9 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 40
Question grep is not working, please find out the problem

HI Friends,


Traxlist.txt --this is my file contains this txt
-------------
108042708190000.txt
108042708190001.txt
112040108174516.txt
112042708173000.txt
112042708174508.txt
112050108173000.txt
113042708100500.txt
113042708103026.txt


i have varible called file1="112042708*.txt"
i need to search this string type in Traxlist.txt and output should be

112042708173000.txt
----------------------

search=`grep $file1 Traxlist.txt`
echo "search :"$search

i tried this one but its not working
can anyone help me out.
  #2 (permalink)  
Old 05-07-2008
jacco jacco is offline
Registered User
  
 

Join Date: May 2008
Posts: 15
The * in a regular expression is not the same as in file expansion.
The * in "112042708*.txt" means '0 or more times an 8'.
If you want a regular expression that matches '0 or more time a random something' use a dot, as in '.*'
  #3 (permalink)  
Old 05-07-2008
grinds grinds is offline
Registered User
  
 

Join Date: May 2008
Posts: 9
try a "chmod 777" on the source file and then run your grep command. it may just be a permissions issue. I have run into this a number of times.
  #4 (permalink)  
Old 05-07-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Quote the variable, try this:

Code:
grep "$file1" Traxlist.txt
Regards
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 11:59 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