473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

egrep issues

19 New Member
Ok , i m playing with egrep command and i am a little stuck in these (i have researched google and MAN pages already ):

1.i need to search files using EGREP in the /var/log directory that contain the word 'su' (case sensitive) at EITHER the END of a line OR the beginning of the line. Add two lines of context AFTER each keyword found. (i can accomplish everything BUT the END of the line with the following command:).

egrep –A 2 ‘^(su)\b’ /var/log/*

2.. Search all files directly under ~ that contain either the word 'whether' or 'wither.' Make sure that each word found is prefaced by the number of the line on which it occurs, and output your results to a file called 'my.search.' (with the following command i get WITHER but no WHETER).

Egrep –n ‘w[hei]ther’~/* > my.search

3.. Find all DIRECTORIES under the current directory which include 'tmp' in its name. (I tried the following command with no luck : )
Find . –name tmp


Any idea anyone in what i am doing wrong here ?

Thank you for your assistance .
Feb 19 '07 #1
2 2715
Motoma
3,237 Recognized Expert Specialist
Ok , i m playing with egrep command and i am a little stuck in these (i have researched google and MAN pages already ):

1.i need to search files using EGREP in the /var/log directory that contain the word 'su' (case sensitive) at EITHER the END of a line OR the beginning of the line. Add two lines of context AFTER each keyword found. (i can accomplish everything BUT the END of the line with the following command:).

egrep –A 2 ‘^(su)\b’ /var/log/*

2.. Search all files directly under ~ that contain either the word 'whether' or 'wither.' Make sure that each word found is prefaced by the number of the line on which it occurs, and output your results to a file called 'my.search.' (with the following command i get WITHER but no WHETER).

Egrep –n ‘w[hei]ther’~/* > my.search

3.. Find all DIRECTORIES under the current directory which include 'tmp' in its name. (I tried the following command with no luck : )
Find . –name tmp


Any idea anyone in what i am doing wrong here ?

Thank you for your assistance .
I am really bad with regular expressions, but here is a great reference site.

The last one might be as simple as "find . | grep tmp" or "find . -wholename tmp"
Feb 20 '07 #2
Colloid Snake
144 New Member
Ok , i m playing with egrep command and i am a little stuck in these (i have researched google and MAN pages already ):

1.i need to search files using EGREP in the /var/log directory that contain the word 'su' (case sensitive) at EITHER the END of a line OR the beginning of the line. Add two lines of context AFTER each keyword found. (i can accomplish everything BUT the END of the line with the following command:).

egrep –A 2 ‘^(su)\b’ /var/log/*
If you're looking for something at the end of the line, you use '$', but the ^ and $ are best used separately. I think you're going to need the * operator (which represents either zero or more of an instance), and parentheses around the ^ and $ markers. Also, the .* is helpful for getting between text.
2.. Search all files directly under ~ that contain either the word 'whether' or 'wither.' Make sure that each word found is prefaced by the number of the line on which it occurs, and output your results to a file called 'my.search.' (with the following command i get WITHER but no WHETER).

Egrep –n ‘w[hei]ther’~/* > my.search
This searches specifically for 'wheither'. You should look into the | (pipe) operator.
3.. Find all DIRECTORIES under the current directory which include 'tmp' in its name. (I tried the following command with no luck : )
Find . –name tmp


Any idea anyone in what i am doing wrong here ?

Thank you for your assistance .
That once again, searches for anything labeled 'tmp', again I think you need the wildcard operator '*' (if you're looking specifically for the regex - Motoma's way is definitely easier).
Feb 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2072
by: Tom Loredo | last post by:
Hi folks- I'm about to move from a Solaris 8/SPARC environment to a Dell running RedHat 9. Are there any issues I need to be aware of in bringing my Python code over (mostly scientific...
28
2765
by: grahamd | last post by:
Who are the appropriate people to report security problems to in respect of a module included with the Python distribution? I don't feel it appropriate to be reporting it on general mailing lists.
5
4672
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
2
2266
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup...
1
1943
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there...
1
3067
by: SSJVEGETA | last post by:
Hello, everybody. I have read some examples and manuals for the egrep command for Linux and I don't know if this egrep command is right for the particular files I am searching for. Here is what the...
3
1636
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors...
32
3198
by: ndedhia1 | last post by:
Right now, I am using this line of code to get rid of data in a file called alarmNotification that I do not want: egrep "low debug.*\".*\"" $dbDir/alarmNotification.log but I am having some...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.