Visit Our UNIX and Linux User Community

Grep returns nothing

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep returns nothing
# 1  
Old 04-28-2010
Grep returns nothing

Hi all,

I am trying to grep a .txt file for a word. When I hit enter, it returns back to $

The file is 4155402 in size and is named in this way:


I use this command, being in the same directory as the file:
grep -i "invalid" *_eveningtimes_done_log.txt

and it returns back to $
# 2  
Old 04-28-2010
It pretty much means that the string you are searching for was not found.
To be sure that is the case tell us what is the output of
grep -ci "invalid" *_eveningtimes_done_log.txt


Last edited by pseudocoder; 04-28-2010 at 04:34 PM..
# 3  
Old 04-28-2010
The string does exist. If i do a head -50 , then i can see the string. I can also see it via opening the file in windows text editor.
# 4  
Old 04-28-2010
Can you post those 50 lines (obfuscating any private data)? It might be that you have some hidden characters. You can use cat -v to check this.

Last edited by Scott; 04-28-2010 at 04:50 PM.. Reason: Fixed typo, removed od
# 5  
Old 04-28-2010
here is the output:


Last edited by DallasT; 04-29-2010 at 03:11 PM..
# 6  
Old 04-28-2010
What environment are you running the grep command in?
# 7  
Old 04-28-2010
bash-3.2$ ?

Can you tell me how to check that?

---------- Post updated at 02:17 PM ---------- Previous update was at 02:13 PM ----------

Originally Posted by pseudocoder
It pretty much means that the string you are searching for was not found.
To be sure that is the case tell us what is the output of
grep -ci "invalid" *_eveningtimes_done_log.txt

0 value is returned.

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exit always returns 0

This returns 0 even when it does not delete any files. Is it because -print returns 0? RETVAL=$? Docs_Backups=/media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/Documents_Backups/ Scripts_Backups=/media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/Script_Backups/ # create some old files #touch -d 20120101... (4 Replies)
Discussion started by: drew77
4 Replies

2. Shell Programming and Scripting

Help in function returns value

Hi, I need to return a value from the function. the value will be the output from cat command which uses random fucntion. #!/bin/ksh hello() { var1=$(`cat /dev/urandom| tr -dc 'a-zA-Z0-9-!%&()*+,-/:;<=>?_'|fold -w 10 | head -n 1`) echo "value is" var1 return var1 } hello var=$?... (2 Replies)
Discussion started by: Nandy
2 Replies

3. Shell Programming and Scripting

If test grep.... always returns 0 status

Hi all. I am trying to compare and filter two files. I have a bigfile.txt of names and ids and a smallfile.txt of ids only. What I am trying to do is use a while read loop to read the ids in the bigfile and then echo the name and id only if the id exists in the small file. Basically, I'm trying to... (5 Replies)
Discussion started by: jameswatson3
5 Replies

4. UNIX for Dummies Questions & Answers

grep returns many values into a variable error

I get an error when I grep my results into a variable when the grep finds more than one file. FND="$(find ediout* -mmin -60)" if ; then STR="$(find ediout* -mmin -60 -exec grep -l "ERRORS Encountered" {} +)" fi When there is only one ediout file it works fine. How do I... (11 Replies)
Discussion started by: aispg8
11 Replies

5. Shell Programming and Scripting

Using grep returns partial matches, I need to get an exact match or nothing

I’m trying to modify someone perl script to fix a bug. The piece of code checks that the zone name you want to add is unique. However, when the code runs, it finds a partial match using grep, and decides it already exists, so the “create” command exits. $cstatus = `${ZADM} list -vic | grep... (3 Replies)
Discussion started by: TKD
3 Replies

6. Shell Programming and Scripting

If the grep command returns any result set

my intension is to use a grep command inside the shell script and if any row is returned or not.. depending on the resultset i have to code on further. how to check this i mean.. could anyone help me out with the if condition how to use it here !! (4 Replies)
Discussion started by: gotam
4 Replies

7. Shell Programming and Scripting

find/grep returns no matches

Hi all! I've faced with very unintelligible error using find/grep like this: root@v29221:~# find /var/www/igor/data/www/ | grep u28507I get nothing as a result, but: root@v29221:~# grep u28507 /var/www/igor/data/www/ $db_name = 'u28507';... (2 Replies)
Discussion started by: ulrith
2 Replies

8. UNIX for Dummies Questions & Answers

Grep without returns...

Is there a command where I can pipe my grep into it and it will output it with spaces rather than returns? Example I want to turn prompt$ grep blah file blah blah into this prompt$ grep blah file | someCommand blah blah (1 Reply)
Discussion started by: mrwatkin
1 Replies

9. Programming

inet_addr() returns 0

Im trying to connect to a particular IP address and I'm tying to use gethostbyaddr() and inet_addr() to do this. However, when I tried using inet_addr(), I always get a return value of 0 when I tried to connect to "". Hope someone here could help me on this. I already tried using inet_... (1 Reply)
Discussion started by: soulfactory2002
1 Replies

Featured Tech Videos