General :: Grepping Grep Output Fails
Feb 5, 2010
I'm trying to grep the output of ngrep. Unfortunately when I add another grep to the pipeline, I get no output at all. It can be some other command too - cat / grep / tee - everything breaks the chain. Example:
[Code]....
If I use cat somefile instead of ngrep at the start, everything works as expected.
View 2 Replies
ADVERTISEMENT
May 17, 2010
I forgot a lot of my command line. I am doing cat file | grep "error" and i would like it to show everything to the right of G:/ including G:/ if possible. I figure its an awk command but i dont know what. I tried awk '{print $8+}' but + does not work like i hoped and guessed.
View 2 Replies
View Related
Mar 6, 2011
Following is my ifconfig output code...
I want to do some thing grep that I see the IP corresponding to each LAN card?
Is that possible?
View 8 Replies
View Related
Feb 15, 2011
I have a requirement to find the files having its name as ack_reply. However, there are many other files in the same directory as these resides. Now I have to remove these files from the folder and retain others after 7 days. So I tried to write the below script with grep command.
find $directory -type f -mtime +7 | grep ack_reply
how can I pass this output to -exec command.
If I am not using grep command my script would be as
find $directory -type f -mtime +7 -exec remove.sh {}\;;
How can I use -exec with grep and find.
View 4 Replies
View Related
Aug 13, 2010
Is there some way to filter output of command by OR condition in Linux? There is filtering by AND condition with grep in way like:
ls -l | grep "^a" | grep "z$"
That says: list all files that beggins with "a" AND ends with "z" (so there is shorter way to write this: grep "^a.*z$", but it is not matter). Is there some way to perform test by OR condition? For example: files that starts exactly with "xen" OR files that ends exactly with ".rpm". But exactly, not something like:
grep "[xen]{0,3}.*[.rpm]{0,4}"
View 2 Replies
View Related
Aug 24, 2010
how I cat to filter out information about Unix Domain Sockets from netstat output without grep? Is there some option for command (I not found it in man of netstat).
View 2 Replies
View Related
Feb 21, 2010
In linux, I can grep a string from a file using grep mySearchString myFile.txt.
How can I only get the result which are unique?
View 1 Replies
View Related
Feb 3, 2010
I would like to grep two numbers out of a text file, and divide them.
Here is the script code...
It feels like grep saves a new line too? or what is happening? i simply can't divide them, as it handles the variables as they are empty (and prints the two numbers although they were not printed
View 6 Replies
View Related
Mar 22, 2010
I have some big files of logs that contain errors printed by an app. They are most of the time relevant, however most of them are similar. So i figured i could check what happened between a time interval with a find.
Im using this one
Code:
And I get an output similar to this one.
Code:
Is there a way to condensate the output lines to get only one or two, indicating the start and last occurrence of a block? Or I need to create a program to do so?
Because right now I get thousands of similar lines, but when I'm scrolling through them i sometimes miss relevant information that i would've otherwise noted if it wasn't all that spammy.
View 10 Replies
View Related
May 3, 2011
I am having trouble using grep command. I want to search for each line in first file in second file and if they are present, write to file called successfile else to failfile. Below is the code
what is happening is, when the first failure occurs (when a line in first file is not present in second file), the script is killed.
Can anyone please tell me what I am doing wrong? code...
View 4 Replies
View Related
Jul 1, 2010
I am in the middle of trying to write my first script. I have created a command using sed and grep to grab a list of ftp hosts from a host file. Now I want to test the ftp connection of the hosts that have been returned after running the command.
grep host config.xml | sed 's/<//g;s/>//g;s/host//g;s/[/]//g' | sort | uniq -d | ftp ftp.hostname.com
I get the below error
Unknown AUTH type.
Unknown AUTH type.
KERBEROS_V4 rejected as an authentication type
Password:Name (ftp.hostname.com:username):
View 7 Replies
View Related
Jan 25, 2011
What If I wanted to scan a string like the following...
[Code]...
Anyhow just one giant string that's longer than my screen's width. If I simply copy and paste that string after a grep command, it seems that the terminal inserts newlines at the terminal's width and therefore not the whole string goes in. Even if I insert a quote before the beginning of the string and then paste it in, terminal still reads in a newlines somehow and obviously says command not found, etc.
View 2 Replies
View Related
Apr 7, 2009
I am trying to use a shell script to find a string in a file and do something when found. code...
What should happen is pppd will start in a different process and stream it's output to pppdout. pppdout should be created in the current folder. Then the script should periodically check the pppdout file for the string Script (which eventually will appear, some seconds later) and when found exit the script. Ultimately the script will do something useful when the text is found. However, the output from the program is a repeating: 'scriptname.sh: 12: FOUND: not found'
Where scriptname.sh would be the name of your script and 12 refers to the line with 'done'.
Why does grep not find the text, or at least why deos my script not check the grep output correctly?
View 10 Replies
View Related
Apr 14, 2010
How can I remove characters from grep output using sed? code...
View 9 Replies
View Related
Sep 1, 2010
So theres this command
Code:
man -k mail
Which lists commands that contain the keyword "mail" in their description.I want the output of this command in less and the words highlighted by grep. Something like
Code:
man -k mail | grep mail | less
The command doesn't work, how do I fix it?
View 2 Replies
View Related
Nov 11, 2010
I want to pipe the output of a command into grep as the search TERM, rather than the text to be searched, like this for example
Code:
cat /var/log/auth.log | grep date "&b &d"
so that I only see the lines in auth.log for the current day...but obviously that line doesn't work.... is there a way to do this with grep, or even another command?
View 4 Replies
View Related
Jul 13, 2011
I am not sure why this does not work..
tshark |grep 'string'
Gives me what I want but
tshark |grep 'string' >/tmp/outputfile
Gives me an empty file.
View 3 Replies
View Related
Jul 28, 2010
I have two files :
FileA
prot1
prot5
prot9
prot15
[Code]....
What I need to do is to extract from fileB the fields containing only the strings in fileA.
I thought awk could do the job easily with :
Code:
awk 'BEGIN { RS = "###" } /'$variable'/' fileB > output
where variable would maybe be the output of grep from fileA. So can I store the output of grep in a variable to use it afterwards with awk ?
something like that:
Code:
result=`grep prot. fileA` ; awk 'BEGIN { RS = "###" } /'$result'/' fileB > output
but that doesn't work. I'm always getting the entire fileB.
The output of grep get stored in the variable, I verified that with echo. So there is something that I just don't get... It seems to me that the above line should work.
View 11 Replies
View Related
May 1, 2011
My script.
This is may script:
Code:
Problem: Output file doest not exclude the values in grep -av
View 3 Replies
View Related
Nov 22, 2010
I need to kind of grep within grep. My input file would be something like:
[Code]....
and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:
[Code]....
View 4 Replies
View Related
Jun 9, 2011
I want to write a script that keeps "grepping" strings from the Main page of the Linksys PAP2T every 30 seconds.It seems to be simple:1- lynx -auth=user:password URL2- grep the strings3- process themthe problem is that the page is writed in PHP and Lynx does not clear the authentication credentials with a 401 server response!w3m works.. but I don't know how to set the autologin and how to export the page to a text.With firefox.. I can set the home page as but it ask if it can continue before sending the data.. how can I force it and how can I obtain a text from it?I don't know.
View 1 Replies
View Related
Apr 7, 2011
I need to find file from ls - l by using grep and certain regexp.
In particular I need greep to see certain file ending, like let's say .txt but only using regex.
So it should be something like
ls -l | grep '^.+.txt$'
But that doesn't seem to work for me.
View 1 Replies
View Related
Dec 21, 2010
I need to grep a dictionary file.Only the words that contain 2 or more z's and only 1 b needs to be listed.
View 1 Replies
View Related
Jul 15, 2010
I am trying to grep for A records in a bind zone file but I am failing.I am trying: grep "s+As+" db.domain.comBut there are no results.
View 12 Replies
View Related
Jul 29, 2010
Today, i checking my error log of Apache. I have look many IP brute scan URLo, i collect, export that to ip.txt and i need grep IP with connection >=8I don't know command to solve that. Example ip.txtQuote:
101 210.13.73.30
161 58.210.77.98
164 115.168.71.87
[code]....
View 2 Replies
View Related
Feb 3, 2010
I have a file which contains a line like this:SERVER=10.205.110.19 How can I cut out the IP and assign it to a variable?
View 4 Replies
View Related
Mar 28, 2010
How can I use grep expressions so that i can find strings like the ones bellow:
New York, NY
Virginia, VA
Oregon, OR
As you can see each city starts with capital letter then it follows up with a comma, and then with the Abbreviation of the city. I used :
Code: grep -w '[A-Z].*[a-z][,][' '][A-Z][A-Z]' filename But i get no results.
View 2 Replies
View Related
Feb 19, 2011
I have on my desktop around five java files. I also created a java file in directory Viti, located in desktop.
Since all java files contain string "class", I practice my usage of grep with the following:
And this works fine. However, when I type the following:
I expect to be shown the file that's located in my Viti directory, too, but it won't show it.
View 4 Replies
View Related
Jul 3, 2010
I searched and I found a few threads on this but none answered my question really.I'm using:
Code:
curl www.foo.com | grep '<h2>.*.</h2>'
Basically I want to extract all instances of
Code:
<h2>Blah blah blah</h2>
from the page source, but it's not giving me that, it gives me <h2>.. followed by a loads of other stuff that I don't want. I haven't used wildcards with grep before so I don't really know whether I'm doing it right or not.
View 5 Replies
View Related
Dec 7, 2010
Let me *try* and explain what I'm trying to do, and keep in mind aside from a little command line stuff I'm a beginner to any of what I'm asking about.
I have a directory structure something like this:
Code:
/usr/local/chatlogs/
webserver1/
1.chatlog
2.chatlog
[Code]....
So that whatever was captured in the () in the first part of the statement would be used in the 1 in the back part of the statement for every n.chatlog that might be in any of the /webserver directories at that time.
View 2 Replies
View Related