grep is not working, please find out the problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep is not working, please find out the problem
# 1  
Old 05-07-2008
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  
Old 05-07-2008
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  
Old 05-07-2008
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  
Old 05-07-2008
Quote the variable, try this:

Code:
grep "$file1" Traxlist.txt

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep with variable not working

Hello, I am using below code : export ORAR=orp712z.int.thomsonreuters.com #echo $ORAR; if echo $ORAR|grep -i "_" then ORACLE_SID1= echo $ORAR|cut -f2 -d "_" echo $ORACLE_SID1 ORACLE_SID=fgrep "$ORACLE_SID1" /etc/oratab|cut -f1 -d ":" #echo $ORACLE_SID else ORACLE_SID1= echo $ORAR|cut... (1 Reply)
Discussion started by: admin_db
1 Replies

2. Shell Programming and Scripting

Working with grep and Bash

Hi, I am currently working on a Bash shell script that - Downloads a webpage, in this case youtube.com - Extracts Number of views, Extracts Title of video, Extracts User who made it, and lastly Duration. Then I have to Out put this into columns. To me this sounds like crazyness. I'm very new... (6 Replies)
Discussion started by: Njzangel
6 Replies

3. Shell Programming and Scripting

Working with grep-output

Hi, 1st post Sorry for borrowing the thread. Hopefully this is doable. I need to write a script where I need to pick information from my grep-results. grep -n "s_" file | head -n 1 Output is like this: 6:s_9: 11-664 Fam_g442_99 So this gives me the first line of the file which... (2 Replies)
Discussion started by: Shell_y
2 Replies

4. Shell Programming and Scripting

How to use grep & find command to find references to a particular file

Hi all , I'm new to unix I have a checked project , there exists a file called xxx.config . now my task is to find all the files in the checked out project which references to this xxx.config file. how do i use grep or find command . (2 Replies)
Discussion started by: Gangam
2 Replies

5. UNIX for Dummies Questions & Answers

grep -f not working

Hello, I'm going crazy about this. I'm using grep to filter some values as in pas -ef | grep asterisk. When I use the same with -f somefile something weird happens, if somefile is created with vi it'll work, if somefile is created with vi but values are pasted from an Excell file it will not work.... (2 Replies)
Discussion started by: seveman
2 Replies

6. Shell Programming and Scripting

grep not working ????

Hi, I've prob in doing grep. I want to grep line staring with number 531250 in the 1st column from a file (example in picture attached below) using command grep -w "531250" file my ideal result should be 531250 1 21 42.1 100 1e-05 ... (8 Replies)
Discussion started by: masterpiece
8 Replies

7. Shell Programming and Scripting

grep is not working for few extensions

HI all, I am trying to grep few words in with file extension of srw. But grep is not giving any output. File has all the permisssions to read,write,execute. If i try to search manually i can notice words whatever i want in the file. my command is very simple grep -i "word" *.srw... (4 Replies)
Discussion started by: spc432
4 Replies

8. Shell Programming and Scripting

find grep whitespace problem

Hey guys iv written a basic function to ask for input location to find then grep a certain string in the file at the location of the find. For some reason it finds the file with the certain string it however it says directory not found on each string before the whitespace eg enter location to... (5 Replies)
Discussion started by: musicmancanora4
5 Replies

9. UNIX for Dummies Questions & Answers

grep not working

This condition is not able to grep , can any one tell what's wrong with this part. I am able to see from unix command but not with host script. echo "Checking for Loader Status " >> $REPFILE if test $? = 0 then echo "Successful termination of SQL*Loader "$LOADER1 >>... (5 Replies)
Discussion started by: u263066
5 Replies

10. UNIX for Dummies Questions & Answers

FIND/GREP problem

When I enter the command below grep appears to be returning a file it shouldn't. find . -name "*.*" -exec grep "testing" {} /dev/null \; .:ops3Mailfile ./SSI.ksh: # create TECHOUT dummy for test for testing purposes ./ftprimi1.ksh:# before running job in prod... change FTP to... (1 Reply)
Discussion started by: dfb500
1 Replies
Login or Register to Ask a Question