As a dummy, I try to search for multiple string of characters contained in 2 types of list.
Not clear? No it's not.
Example:
I have a tab-delimited file called "inventory" with 2 columns that looks like that:
A file "list1.tab" contains:
Another file "list2.tab" contains:
Using egrep, I would like to extract the lines from the file "inventory" that contain both ONE of the terms from "list1" AND one of the term from "list2".
In a way I should obtain only:
Here it is just an example.
In reality my file "inventory" contains about 100,000 lines, the list1.tab and list2.tab about 100 terms each.
Is it possible to use egrep to write something with this meaning:
egrep '(<one of the term from list1>)*(<one of the term from list2>)'
I don't really care of the column "ref".
I hope I have been clear enough !
I can definitely give more explanation if needed.
Thanks balajesuri, it works but the second method is definitely easier !
---------- Post updated at 08:09 PM ---------- Previous update was at 07:16 PM ----------
I am wondering...
Once the lines containing the matching terms from list1.tab and list2.tab have been extracted, would it be possible to print the corresponding ref. AND only the matching terms (separated by a pipe, a coma, a space, or whatever) instead of the whole line?
Or if you prefer, a way to discard everything except the matching terms from the 2 lists and the corresponding ref?
Like that:
I tried the option -o in any possible way, but it doesn't work.
Input:
I have input file below mentioned.Input file has Yahoo,gmail,yuimn etc..are websites and there are users listed under it. I have many other unique websites but i mentioned just few as below.
For example: Yahoo is website and 123,fsfd are members of website "yahoo". See below input... (19 Replies)
Hi all,
i have the bash script for remote conection,
for hosts in $(cat /list); do
ssh user1@$hosts "hostname";
done
execute hostname command by all hosts and show standar ouput,
how i can send to file by each host in lists, so
e.g.
$cat list
10.0.0.1
10.0.0.2... (1 Reply)
Hi Everyone !
I have two files with the same configuration
and I want to multiply corresponding values and write the result in a file.
Let say 2 header lines and then lines of values (with not constant number of columns):
more file1.txt -->
BLABLABLA
BLABLABLA
1 2 3 4
1 2 3
1 2
1... (7 Replies)
Hi,
I've been asked to 'troubleshoot' a webserver where two different TLDs are being served. Or to be more accurate, 'domain.com' and 'domain.fr'.
So we have
/var/www/domain.com
/var/www/domain.fr
And then for some reason, the httpd.conf file points to two different configuration files.... (1 Reply)
Hi all,
I'll like to search a list of tems in a huge file and then output each of the terms to individual files. I know I can use grep -f list main.file to search them but how can I split the output into individual files? Thank you. (6 Replies)
In advance, I appreciate any help or tips. I apologize for not providing examples of scripts I have already tried, the reason is that I am new to programming and do not really no where to start. I think this is possible with awk, but do not know how to go about learning how to write the script... (2 Replies)
Hey guys,
Sorry for the basic question but I have a lot of files that I want to separate into groups based on filenames which I can then cat together. Eg I have:
(a_b_c.txt)
WB34_2_SLA8.txt
WB34_1_SLA8.txt
WB34_1_DB10.txt
WB34_2_DB10.txt
WB34_1_SLA8.txt
WB34_2_SLA8.txt
77_1_SLA8.txt... (1 Reply)
I have a list of pattern in a file, I want each of these pattern been searched from 4 files. I was wondering this can be done in SED / AWK.
say my 4 files to be searched are
> cat f1
abc/x(12) 1
abc/x 3
cde 2
zzz 3
fdf 4
> cat f2
fdf 4
cde 3
abc 2... (6 Replies)
Hi all,
what will be the code to compare count present in two seperate files
for e.g file (a) contains counts
100
and file (b) contains records
90
since both these files have differnt count so it will display count didnt match
and in case of success it display (5 Replies)