- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Searching within files for "*"
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2000 08:31 AM
08-15-2000 08:31 AM
I have to search through a large directory for all occurences of a string i.e. DAVE and from these I must exclude where there is an asterisk in column 7. i have used the following and am not getting the right answer.
find . -name "*.fil"|xargs grep -l DAVE|xargs grep -l "DAVE *"
The problem I believe is because I am looking for an asterisk in pos 7.
Any clues?.
Thanking you in advance.
Dave
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2000 08:41 AM
08-15-2000 08:41 AM
Re: Searching within files for "*"
find . -name "*.fil" -exec grep -l "^DAVE \*" \;
That is a backspace before the asterisk in the grep string and a backspace before the ;
Regards
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2000 08:48 AM
08-15-2000 08:48 AM
Re: Searching within files for "*"
To get a list of files that contain the string "DAVE" but do not have a record with an * in column 7 try:-
find . -name "*.fil" -exec grep -l DAVE {} ;| xargs grep -l "......\*";
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2000 09:23 AM
08-15-2000 09:23 AM
Re: Searching within files for "*"
find....(blah blah)... grep -l -v "^......\*"
remember the ^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 04:25 AM
08-16-2000 04:25 AM
Re: Searching within files for "*"
My problem requires me to only select files initially with DAVE and excluding those with 'DAVE *'.
I managed to get the right answer with the following script but I hoped someone may had had a more efficient way.
find /dirname -name "*.fil"|xargs fgrep -i DAVE | fgrep -iv
"DAVE *"|cut -d/ -f6|cut -d: -f1|sort -u
The fgrep has less functionality I believe but it accepts and * for an *
Thanks once again.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 04:51 AM
08-16-2000 04:51 AM
SolutionProviding the lines always start DAVE and have at least 7 characters (ie none just DAVE) then you could get the find command to do most of the work:-
find /dirname -name "*.fil" -exec grep -l "^DAVE..[^\*]" {} \; | cut...
Here grep will select files that have a line which starts DAVE
Hope this helps...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 10:44 PM
08-16-2000 10:44 PM
Re: Searching within files for "*"
find / -name "*DAVE*.fil" | grep -v "DAVE*"
Success
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 10:48 PM
08-16-2000 10:48 PM
Re: Searching within files for "*"
this one, whith a blackslash before the asterix in the grep part.
find . -name "*DAVE*.fil"|grep -v "DAVE\*"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 10:48 PM
08-16-2000 10:48 PM
Re: Searching within files for "*"
find / -name "*DAVE*.fil" | grep -v "DAVE*"
Success