Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-05-2002, 10:31 AM   #1
LQ Newbie
Registered: Aug 2002
Posts: 15

Rep: Reputation: 0
Post Shell-script: search item in any order

Hello altogether,

I have got the following problem:

- every line in a textfile corresponds to a data record
- now i want to search for a certain data record with grep e.g.

so far so good.

But what, if I want to use several search items (and I don't no their order in the data record) at the same time to serach for a dedicated data record??

Quasi "grep PATTERN1&PATTERN2 /home/file" whereupon it doesn't matter in which order "PATTERN1" and "PATTERN2" occurs in "/home/file".

Has anybody an idea??
Old 08-08-2002, 08:03 PM   #2
LQ Newbie
Registered: Aug 2002
Location: Canada
Distribution: RedHat 7.3
Posts: 3

Rep: Reputation: 0
try awk instead.
Old 08-09-2002, 12:52 AM   #3
LQ Newbie
Registered: Aug 2002
Posts: 15

Original Poster
Rep: Reputation: 0

I've got an easy solution interim:

grep PATTERN1 file | grep PATTERN2

Anyway thank you for answering.
Old 08-13-2002, 10:44 AM   #4
Registered: Jul 2002
Location: Chicagoland
Distribution: Gentoo, Ubuntu
Posts: 63

Rep: Reputation: 15
Look at Regular Expressions. Perl supports them internally and it will help you find and/or parse data easily. There should be many tutorials and/or references available online.

good luck


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
startup script order berrance Linux - Software 4 10-13-2005 02:49 PM
mozilla xpm kmenu item desktop item cjae Linux - Newbie 3 04-06-2005 07:11 AM
Search and replace text in file using shell script? matthurne Linux - Software 2 11-02-2004 10:11 AM
Search for a file using shell script sharathkv Linux - Newbie 2 08-06-2003 05:05 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration