Sponsored Content
Top Forums Shell Programming and Scripting Egrep not working with -f option Post 302786939 by siramitsharma on Thursday 28th of March 2013 12:19:10 PM
Old 03-28-2013
egrep -f & awk

Just summarizing my requirement once again

there is file 1(cloumn 5,6) from which new file3 needs to be created with patterns not matching from file2. So i used first grep -f to find out the records having the same & then using -v i was trying to create file3 which failed(code tag already given at first instance). Then i tried awk which also didnt gave required output

Code Tag 1 using grep:
Code:
grep -vf $FILE2 $FILE1 > $FILE3

jim thanks for the suggestion but breaking such huge file will be an issue for me & then collating the same again will be cumbersome.

So i tried awk in single output as suggested but didnt worked either, please help

Code:
awk 'NR=FNR {
BLACK[$1]=1 ; next }
{for (count=5;count<=6;count++)
$count in BLACK
}
1
' $FILE2 $FILE1

FILE1:
Code:
9123,2425982,201311002,6,11111,1231
9123,2425982,201311002,6,203011000,12345
55777,1234567890,20131101111,5,26700,1234

File2:
Code:
1231
203011000

File3(output: as 1231 is present in 6th column and 203011000 is present in 5th column):
55777,1234567890,20131101111,5,26700,1234

Last edited by Scrutinizer; 03-28-2013 at 02:52 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

egrep -e not working...!

:cool: fedora core 2 version 2.6.8-1.521 gnu/linux the last version of redhat that I was working with linux 8.0 a special version that came with a book.. on this version and on spider tools linux 0.9 the second version I worked with.. when i envoked egrep -e from file1 to file2 I would get the... (4 Replies)
Discussion started by: moxxx68
4 Replies

2. Solaris

Why does the 'ps' command with -u option not working?

How can I use the 'ps' command to view current sessions but only for a given process/user, with the -u parm? In older versions of Unix, this used to work, but not in Sun Solaris. Thanks (4 Replies)
Discussion started by: ElCaito
4 Replies

3. UNIX for Dummies Questions & Answers

-d option not working...

:confused: In the following, when I enter a valid, existing directory,why am I getting Not Found when the Dir DOES exist? read auser echo "You entered $auser" wait 2 cd /home if then echo "Dir Exists" sleep 2 else echo "/home/$auser Not Found" sleep... (2 Replies)
Discussion started by: rgouette
2 Replies

4. UNIX for Dummies Questions & Answers

egrep with |, only second option matches

hey cat links.html | egrep "<title>" works cat links.html | egrep "<link rel" works too, but: cat links.html | egrep "<title> | <link rel" (only shows the matches of '<link rel') and cat links.html | egrep "<link rel | <title>" (only shows the matches of '<title>') don't work :( i... (2 Replies)
Discussion started by: KarelVH
2 Replies

5. HP-UX

who command option not working

Running HP 11.31 on a HP3600. But when I log in as a user the who command works but if I use an option like "who -m" I get nothing. Any thoughts on what is causing this problem. (11 Replies)
Discussion started by: KMRWHUNTER
11 Replies

6. Shell Programming and Scripting

matching a regex using egrep not working

Hi, I'm trying to validate if a string matches a regular expression, but it is not working. Am I missing something? Do I need to scape any of the characters? if echo 'en-GB' | egrep '({1,8})(-{1,8})*' >/dev/null; then echo Valid value fi Thanks in advance (6 Replies)
Discussion started by: skrtxao
6 Replies

7. UNIX for Dummies Questions & Answers

~c is not working properly with -r option

Hi There, --------- file1 ------- ~c asd@ac.com -------------- Now i am using below command cat file1|mailx -s " testing" -r " My Name" abc@tech.com (3 Replies)
Discussion started by: Tapan Sharma
3 Replies

8. Shell Programming and Scripting

-v and -f option for grep not working

In solaris, i m trying to find the files having a particulat extension and then from the list i want to exclude those files which is present in a file. But it seems the -f and -v option are not working find $source -type f -name $extn | /usr/xpg4/bin/grep -F -v -f $exclude | while read... (7 Replies)
Discussion started by: millan
7 Replies

9. AIX

SQLPLUS -S option not working

Hi All, I am using the following script to run some sql on database but i am not getting the result. When i tried the same by removing "-s" option it is working fine but getting other things as well with my input as shown below. Can anyone please suggest why "-s" option is not working in AIX and... (2 Replies)
Discussion started by: ssk250
2 Replies

10. UNIX for Beginners Questions & Answers

Egrep command is not working for me

my file is below REREGISTER is something to Failed to create the request Failed to create the request in not easy I know how REREGISTERcommand i run is egrep 'REREGISTER|Failed|to|create|the|request' test1 expected output REREGISTER is something to Failed to create the request i should... (2 Replies)
Discussion started by: mirwasim
2 Replies
JOIN(1) 						      General Commands Manual							   JOIN(1)

NAME
join - relational database operator SYNOPSIS
join [ options ] file1 file2 DESCRIPTION
Join forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. If file1 is `-', the standard input is used. File1 and file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in each line. There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con- sists of the common field, then the rest of the line from file1, then the rest of the line from file2. Fields are normally separated by blank, tab or newline. In this case, multiple separators count as one, and leading separators are dis- carded. These options are recognized: -an In addition to the normal output, produce a line for each unpairable line in file n, where n is 1 or 2. -e s Replace empty output fields by string s. -jn m Join on the mth field of file n. If n is missing, use the mth field in each file. -o list Each output line comprises the fields specifed in list, each element of which has the form n.m, where n is a file number and m is a field number. -tc Use character c as a separator (tab character). Every appearance of c in a line is significant. SEE ALSO
sort(1), comm(1), awk(1) BUGS
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort. The conventions of join, sort, comm, uniq, look and awk(1) are wildly incongruous. JOIN(1)
All times are GMT -4. The time now is 01:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy