LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-23-2005, 06:58 AM   #1
palanisaravanan
Member
 
Registered: Oct 2003
Location: India
Distribution: Debian
Posts: 95

Rep: Reputation: 15
Angry Need a help with grep


I am having some 50 files where each file has 10 lines.one particular
string is present in some files where it is not there in other files.
I am trying to find the name of the files where the string is not present
and move the the output to a file for further processing.
I tried the following command

grep -l -v 'string' filename>test



But it is still showing the files where the string in present.

Can any one help me to sort out the problem?
 
Old 04-23-2005, 07:10 AM   #2
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
You need to write script something like as follows

Code:
A="ALL FILE NAMES"
for i in $A
do
  grep "string" $i>/dev/null
  [ "$?" != "0" ] && echo $i notfound.txt
done
notfound.txt == list of files in which string does not exists
 
Old 04-23-2005, 07:59 AM   #3
palanisaravanan
Member
 
Registered: Oct 2003
Location: India
Distribution: Debian
Posts: 95

Original Poster
Rep: Reputation: 15
Do u want me to pass all the 100+ files to the variable A ??
 
Old 04-23-2005, 02:33 PM   #4
ataraktos2
LQ Newbie
 
Registered: Apr 2005
Posts: 7

Rep: Reputation: 0
try something like this for the for statement:

for i in 'ls'
 
Old 04-24-2005, 03:22 AM   #5
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Quote:
Originally posted by palanisaravanan
Do u want me to pass all the 100+ files to the variable A ??
Yes you can write

A="$1"

And run script as

script "/path/to/files/*"
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep ?? can grep us variables? DaFrEQ Linux - Software 4 09-14-2005 12:22 PM
about grep ringerxyz Programming 1 03-03-2005 01:52 AM
What does rpm -qa |grep th* (as compared to rpm -qa |grep th) display? davidas Linux - Newbie 2 03-18-2004 01:35 AM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 03:11 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:26 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