473,569 Members | 2,729 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 2723
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
2073
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 computation)? In particular, I know earlier versions of RH shipped with an "old" Python installed as "python" and that installation of more recent versions...
28
2774
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
4675
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 know how will the speed be, what is the memory overhead involved, etc during database specific operations (retrieval, update, insert, etc) when MySQL...
2
2280
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 windows where you can edit information and data, nothing out of the ordinary. I estimate we have something like 50 to 100 tables and/or views in...
1
1958
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 issues? Differences? Should we switch our dev environment to 64bit. What is the advantage of going with 64 bit servers other than being able to...
1
3070
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 question says: Read documentation about the Unix egrep command. Then, write an egrep command that will search all files, in the current...
3
1645
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 which take a while to fix because the error stink: Forget to set ASP.NET 2.0="Parser Error Message: Could not load type" '*.Global' is ambiguous:...
32
3208
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 problem. An entry like the one below in the alarmNotification.log file is getting deleted when I only want a part of the entry to be deleted,...
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2111
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 we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.