Sponsored Content
Top Forums Shell Programming and Scripting Searching the content of one file using the search key of another file Post 302910943 by csim_mohan on Tuesday 29th of July 2014 07:30:31 AM
Old 07-29-2014
Thank you very much for the clear explanation about awk. The grep script works perfectly fine but just one another concern. If in case my output is just the same as above but with a slight change like this, if the search is found it has to return the whole line else just the first column
Code:
hello.com    neo.com,japan.com,example.com 
news.net     
example2.com    earth.net, abc.gov.uk

Any suggestions in this ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching and Removing File Content

Hi, I am trying to search a character in a file and remove it from that file.... My file looks something like this: test1.txt ckj12300_00|123|var1|10.2 ckj00200_12|444|var2|11.2 ckj00200_14|4556|var3|33.5 c00200_00_000|4558|var4|33.5 ckj00200_14|4553|var5|33.5... (7 Replies)
Discussion started by: rkumar28
7 Replies

2. Shell Programming and Scripting

searching for filenames with search strings in another file

Hi, I have 5 files in a directory. emp1_usage.txt emp2_usage.txt emp3_usage.txt emp4_usage.txt emp5_usage.txt I am using sqlldr to get the contents of the above 5 files and store it in a temp table and update my original table using temp table. for f in *emp*.txt do sqlldr... (3 Replies)
Discussion started by: pathanjalireddy
3 Replies

3. UNIX for Dummies Questions & Answers

Searching for key word within a file

Hello, I have a directory that holds all of my matlab codes. I am trying to run a searh on all of the matlab files that have the word "while" written inside the sytax of the code. Looking for all of the times that I did a while loop. Can someone help me do this? Thanks in advance. ... (1 Reply)
Discussion started by: moradwan
1 Replies

4. Linux

How to search file content

Hi folks, What will be an easy and effective way searching file content? E.G I need to find a WORD or a PHRASE on a file? TIA B.R. satimis (4 Replies)
Discussion started by: satimis
4 Replies

5. UNIX for Dummies Questions & Answers

Searching a file with exclusion in the search

Hello, I'm looking for a bit of help. Im trying to search a file for lines that contain white spaces at the end of the lines. This is what I'm using where $param is the path and file name and it redirects the output to a txt file : echo | grep -n ' $' $param >> $2 Is it possible to have... (8 Replies)
Discussion started by: gintreach
8 Replies

6. Shell Programming and Scripting

Search Key in same file but at different positions

Hi All, I want some help in unix. Current code is for DOC in `InputFileName | awk '{ if ( substr($0, 392, 1)=="C") { $0 = (substr($0, 28, 15) "" substr($0, 386, 3)) } else { ($0 = substr($0, 28, 18))}; print }' | sort | uniq` do grep ${DOC} InputFileName > DOCKET_${DOC}.txt done ... (18 Replies)
Discussion started by: kam786sim
18 Replies

7. UNIX for Dummies Questions & Answers

Using File Browser to search file content ...

Hello, I'm using rhel6. Using File Browser Nautilus 2.28.4 I could easily locate any file I'm interested in by it name. I'd like to use this File Browser to locate the file name based on it content e.g. based on some word in the text file. It doesn't work for me that way ... My question: does... (0 Replies)
Discussion started by: susja
0 Replies

8. Red Hat

Moving of file content to another two files after searching with specific pattern

Hello, Please help me with this!! Thanks in advance!! I have a file named file.gc with the content: 1-- Mon Sep 10 08:53:09 CDT 2012 2revoke connect from FR2261; 3delete from mkt_allow where grantee = 'FR2261'; 4grant connect to FR2261 with '******'; 5alter user FR2261 comment... (0 Replies)
Discussion started by: raosr020
0 Replies

9. Shell Programming and Scripting

Search the key from a file to another file

Hi, I need help in solving the below need in UNIX. I have a file datafile as below pg1,dvn1,scls1,cls1,itp1,sku1 pg2,dvn2,scls2,cls2,itp2,sku2 and keyfile as below scls1,1000,a,b,c,d,p1 scls2,1001,a,b,c,d,p1 scls1,1000,a1,b,c,d,p1 scls2,2000,a,b,c,d,p1 (4 Replies)
Discussion started by: bhaski2012
4 Replies

10. UNIX for Beginners Questions & Answers

Search for specific key in a file and print it

Hi All, I have a file abc.txt Database unique name: NEPAL Database name: NEPAL Services: NEPAL_COB,NEPAL_PROD output i need is it should search "Services" and it that search "COB" word so output i need is like NEPAL_COB (3 Replies)
Discussion started by: amar1208
3 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 07:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy