LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Closed Thread
  Search this Thread
Old 12-30-2010, 05:45 AM   #1
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Rep: Reputation: 135Reputation: 135
grep multiple file


I want grep multiple files:

let abc.1.abc.2,abc.3,abc.4

I use grep <pattern> abc.* to read the files. But here grep read files in the order of 1,2,3,4 . I want to to grep the files in reverse order like 1st the abc.4 file will be read and abc.1 file will be last.

Is this possible ?
 
Old 12-30-2010, 05:51 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

grep xyz $(ls -r abc.*)

Hope this helps.
 
1 members found this post helpful.
Old 12-30-2010, 06:02 AM   #3
Trumpen
LQ Newbie
 
Registered: Dec 2008
Location: Italy
Distribution: Debian & Ubuntu
Posts: 11

Rep: Reputation: 0
If your shell provides "brace expansion" you could use it:

Code:
grep <pattern> abc.{4..1}
 
Old 12-30-2010, 06:21 AM   #4
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Original Poster
Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by Trumpen View Post
If your shell provides "brace expansion" you could use it:

Code:
grep <pattern> abc.{4..1}
This may help,but I dont know the number of files.
 
Old 10-26-2011, 01:44 AM   #5
zonah12
LQ Newbie
 
Registered: Oct 2011
Posts: 5

Rep: Reputation: Disabled
grep multiple words

Thankyou so much for the solutions but its not working. I will try to elaborate by giving more examples.
file TOP.txt

Foul
Tall
blot
grail
House
System
Galaxy
jar
trophy
laptop

This file contains 10 words

Second file all.txt


system ns01
broad ns02
house ns03
laptop ns04
trophy ns05
ginger ns06
foul ns07
dustbin ns08
mugs ns09
blot ns10
pack ns11
butter ns12
jar ns13
knife ns14
kangroo ns15
galaxy ns16
kind ns17
heart ns18
grail ns19
short ns20
tall ns21
table ns22
chair ns23
blot ns24
onion ns25
foul ns26

this file contains 26words with their codes, now what i want to do is to relate the top file words with the codes in all.txt files omiting the words which are not present in the top file. that is i want the result to look like this
Result
Foul ns26
Tall ns21
blot ns24
grail ns19
House ns03
System ns01
Galaxy ns16
jar ns13
trophy ns05
laptop ns04

two things important firstly words are not arranged alphabetically and secondly they are not case sensitive that is similar words might be in small alphabet in top file where as in capital in all file.
I hape i have given the clear e.g. now
 
Old 10-26-2011, 04:51 AM   #6
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
@zonah12: You are already receiving answers in your other thread:
http://www.linuxquestions.org/questi...r-file-909296/

Please do not crosspost and keep the discussion in one place.
 
  


Closed Thread


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
grep multiple values in single pass through log file. 1ankit1 Programming 2 11-13-2010 04:45 PM
Multiple grep outputs appended to single row of CSV file findme.krish Linux - Newbie 5 09-12-2010 06:56 PM
Grep an entire file but must contain multiple words wakeboarder3780 Linux - Newbie 10 02-19-2009 04:46 PM
shell script having multiple grep statements-I want input file to be read only once mukta9003 Linux - Newbie 4 08-27-2008 12:58 AM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 07:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:50 AM.

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