General :: Grep - Filtering Output By OR Condition

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


ADVERTISEMENT

General :: Filtering UDS From Output Of Netstat Without Grep?

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

General :: Filtering Out Duplicate Lines From A Find/grep Output

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

General :: Grep - Output Show Only Right Of?

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

General :: Grep IPs From Ifconfig Output?

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

General :: Exec Command With Grep Output?

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

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 View Related

General :: Filter Out Unique Results From Grep Output?

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

General :: Can't Save Grep Output Into Variable / Solution For This?

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

Programming :: How To Get Grep Output 0 - 1 And Test It

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

Programming :: Remove Characters From Grep Output?

Apr 14, 2010

How can I remove characters from grep output using sed? code...

View 9 Replies View Related

Ubuntu :: Output Of Command In Less And The Words Highlighted By Grep?

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

Ubuntu :: Piping Command Output Into Grep As Search Term?

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

Ubuntu Servers :: Using TShark And Grep - Output Empty File?

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

Programming :: Storing Grep Output To Feed Awk To Retrieve Entire Records Matching Variable

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

General :: Writing Else If Condition In Makefile?

Mar 18, 2010

I need to write an else-if condition in a makefile, and though the format is posted on several websites, nothing seem to be working, andI get an error everytime. Could anybody please write a small example with an else-if conditional in a maekefile?

View 1 Replies View Related

General :: Command Line - Recursive Rm With Condition?

Mar 13, 2011

I have the following folder structure:

parent
- folder1
- main1.x
- main1.y

[Code].....

So, how can I achieve this?

View 2 Replies View Related

General :: Put ELSE For Condition Block Of Procmailrc Recipes

May 2, 2011

How can I have ELSE condition in procmailrc I mean if the mail was from X and Subject has Y OR .... DO something ELSE DO SOMETHING ELSE. I do not want to use two different conditions for each state I want use just one condition and its ELSE because putting too recipes in procmailrc make it too slow .

View 2 Replies View Related

General :: Syntax Error In Shell Script While Using If Condition?

May 28, 2011

I am writing a simple shell script where it checks the condition using if condition.

Code:
if [ $name == "JOHN" ] then admin='YES'; fi
if I use like this I am getting below error

[code]....

View 1 Replies View Related

General :: Use A Global Variable To Apply A Condition Within A Script

Feb 28, 2011

I'm trying to use a global variable to apply a condition within a script.

The idea is to use this variable set to e.g. 1 or 2 to run a different part of the script accordingly. I can set the global variable with e.g.

Code:
export WL0=1

run my part of script, increment it by 1 with e.g.

Code:
WL0=$((WL0+1))

but if I re-run the script my WL0 is still set to 1!

I've also tried to add an

export $WL0 at the very end of my script (after the math) but this doesn't change the global variable apparently.

View 15 Replies View Related

Programming :: Variable String File Base - Output File Doest Not Exclude The Values In Grep -av

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

General :: Remort Loging - Check For A File Existince And Display A Message - If Condition

May 31, 2010

I want to ssh and check for a file, I hve came up with following, and its not working,

Is this possible or do I have to do this in a another way.

View 5 Replies View Related

General :: Filtering Daemons List?

Feb 10, 2011

How do i filter the daemoms list for just 1 letter and then turn off certain run levels for that daemon?

View 2 Replies View Related

General :: Tcpdump Filtering Remote Interface?

Jan 28, 2011

I'm trying to capture traffic between two machines, A and B. I would like to make sure that the traffic I capture with tcpdump is between eth1 on the local machine and eth0 on the remote machine. As I understand it, the -i flag specifies the local machine interface - but how to set the remote one?

View 3 Replies View Related

General :: Inexpensive Web Content Filtering Options For Home Use?

Feb 18, 2011

I've been using an old Fortigate-60 at home for the kids for some time but now the license is expired again. Are there any free or inexpensive alternatives? I'd like something I can run on a linux firewall and share against multiple users, with different profiles. In the past I ran squid and I whitelisted sites each kid was allowed to use but this becomes tedious as the kids get older and need access to more. I'd love something that could check a website rating or category list, let the user through for certain categories, and block bad or unrated sites. I don't really need virus checking or email scanning or the like.

View 1 Replies View Related

General :: Software Rec - Firewall With Application-level Filtering?

May 20, 2011

Are there any firewalls for Linux that will allow one to block certain ports for a specific application while allowing other programs to use the same port, or block Internet access altogether for specific applications?

Everything based on IPTables apparently can only block ports globally for all applications. SELinux is the only thing I've found so far that might have application-level Internet blocking capability, but it serves a broader array of security purposes and seems too complex for this task.

I don't need interactive popups like with Windows personal firewalls. I'm OK with having to edit a config file. This is for personal desktop Linux use, not a server.

View 1 Replies View Related

General :: Evolution 2.28.3 Message Filters Not Filtering To Assigned Folders?

May 27, 2010

I have created custom rules following: edit > message filters > incoming filter > (custom filter), none work. Also, by right clicking a message and, create rule from message > filter based by subject, sender, and recipients. Accepting all default (auto populated) conditons. None of the filters work at all? Seems this is a popular problem that has not found a solution except to use Thunderbird. not including ThunderbirdWhen I select a message that is supposed to be filtered to a specific folder and go to Message > Apply Filters. message goes to the assigned folder, but I want it to skip the inbox all together.

View 5 Replies View Related

Programming :: Input File - Grep Within Grep

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

Programming :: Suspend Pthreads Without Condition

Jun 29, 2010

I just started with Pthreads and don't really know much about it. I want to suspend pthreads but apparently, there is no such function as pthread_suspend. but I don't understand why we need both mutex and condition to suspend and resume a pthread. Is it possible to suspend and resume it without using conditions?

View 1 Replies View Related

Programming :: Awk: Swap Fields Given A Condition?

Oct 8, 2010

I have a file records as follows:

Jane pepe@pepe.biz
john@pepe.net John
Joe joe@willxyz.org

How can I get that always first field be given name and second one be the mail address?

I've tried

Code:

awk '$1 ~ /@/ { a=$1 ; $1=$2; $2=a; print }' file

But that doesn't worked

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved