I wanted to use grep to search some files containing code - and the result was very disappointing: although I could see with my own eyes the expressions (written in the files), grep didn't give any output.
Basically, I write this to the terminal
or
in a folder in which some txt files have the word Find in them. Some file also contain some variants like Find, ["Find"], ["FindAllChi..."], etc. I don't get any output, i.e. grep doesn't say file blablabla.txt contains Find or bla2.txt contains FindAllCh..
If I'm editing a file to contain just one line of code, grep finds what I'm looking for.
Can you give some suggestions on how to make grep working?
Thank you!
PS I'm using cygwin 2.5.1(0.297/5/3) on a 64 bits Windows 7 machine.
If this problem occurs on a Windows system, I would start by looking for extraneous <carriage-return> characters in the script you're running. For example if the grep line in the script is:
where <CR> is a carriage-return character, instead of:
the only you're likely to get is a diagnostic saying it can't open a file named *.txt<CR>
and the <CR> in the diagnostic will be invisible unless the diagnostic quotes the filename (in which case you end us with a quote at the start of the diagnostic instead of at the end).
Please show us the output from the command:
where script_name is the name of your shell script containing the grep command. (And, obviously, please show us all of the output produced when you run your script and the exact command line you used to invoke your script.)
Hello,
First of all, I'd like to say hello to all members of forum.
Can You please help me with the matter described below?
I am trying to fetch a data from the file to variable, I am doing this using below script:
returned=`tail -50 SapLogs.log | grep -i -E "Error|"`
echo $returned
... (2 Replies)
I ran the following grep and sed command.
grep "\t" emp.txt
sed -n '/\t/p' emp.txt
grep treated the '\' as to escape t and took the pattern as literal t whereas sed took the pattern as tab.
That means , grep doesn't understand escape sequence!!!!!!
what to do to make grep... (8 Replies)
Hi,
I'm trying to write a script that checks gvfs to see if a mount exists so I can run it from network-manager's status hooks. I thought I'd pipe the output of gvfs-mount -l to grep for the particular mounts I care about. When I do this in a bash script:
cmnd="gvfs-mount -l | grep -i... (4 Replies)
Here's some sample output and my code follows it. Why can't find() find '|'. It just dosn't make a bit of sense at all.
AL01463|Pell City|Saint Clair|B|02115|AL|35125|630|Birmingham (Ann and Tusc)|13890|40|Charter Communications|Fairfield|Charter Communications|2
-1... (1 Reply)
Hi all,
I need some help. my shell script doesn't work especially in the loop.
#!/bin/sh -xv
export ORA_ADMIN=/oracle/home/admin
export ORACLE_SID=ORA_SID
cat ${ORA_ADMIN}/param_alert_log.ora | while read MSG
do
#echo $MSG
#echo "tail -400... (8 Replies)
Hi there,
the following script doesn't work. the first part works, then the second 'grep' fails with ': not found'. However, if I take out the second part (starting with the grep command) and put in a seperate script, it works.
everyone know what's wrong here? no two 'grep' in one script, that... (2 Replies)
I am trying to find only those entries where 7018 and another number appear in the end of the line.
7018 2828 1423 2351
7018 2828 14887
2828 7018 1222
123 7018 1487
I am looking for a way to generate only the last two lines. I was trying to do just "grep '7018{1,5}" but it does not... (5 Replies)
grep -e doesn't work in Soalris.
Same script with grep -e worked on AIX/HP/LINUX..
I would like to search a list of patterns on "log.txt" like ...
grep -e FATAL -e ERROR log.txt
I get the error message as
grep: illegal option -- e
Usage: grep -hblcnsviw pattern file . . . (3 Replies)
how do i check a file for a pattern and perform an action if it doesn't exist?
i know how to search a file for a pattern. you just place it in an array like so.
#!/usr/bin/perl
my $data_file = "file.txt";
open DATA, "$data_file";
my @array_of_data = <DATA>;
if ($_ =~ m/pattern/i) {... (4 Replies)
I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong.
When I copy and paste it to the terminal, it is OK. Any idea what the problem might be?
set i = `grep -c #define flags.h`
while ($i>20)
@ i--
my func (`cat... (4 Replies)