Grep a pattern given in one file at other file and display its corresponding contents as output.
*****************************************
Right now i have this current system.
I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg.
The yyy.txt with lot of lines. eg:
My output is to search the pattern given in xxx.txt at yyy.txt and display the corresponding line as output.
Eg output: this is the line1 which is suppose to be grepped and displayed as a output.
The following script does this.(thanks rdcwayx for giving this solution)
*****************************************
My proposed system is as follows.
eg:
I have two files say aaa.txt and bbb.txt.
aaa.txt with list of patterns in double quotes and its corresponding output which has to be displayed.
bbb.txt with lot of lines. eg:
my requirement is to search the pattern given in double quotes in aaa.txt at bbb.txt and if it exists in bbb.txt, the corresponding pattern after = sign in aaa.txt should be displayed.
Eg output: line one found
Please let me know if i am not clear.
Last edited by Franklin52; 02-22-2011 at 03:05 AM..
Reason: Please use code tags, thank you
Is it possible to get the line number of the occurrence along with the output? from the above example, "this is the line1 which is suppose to be grepped and displayed as a output." is at second line. So the output should be as,
Thanks for your contribution.
I am facing one more challenge. Please help me.
My proposed system is as follows.
eg:
I have two files say aaa.txt and bbb.txt.
aaa.txt with list of patterns in double quotes and its corresponding output which has to be displayed.
bbb.txt with lot of lines. eg:
Requirement 1 : my requirement is to search the pattern given in double quotes in aaa.txt at bbb.txt and if it exists in bbb.txt, the corresponding pattern after = sign in aaa.txt should be displayed.
Requirement 2 : If there is any line which has a 10 digit pattern starts with AA, the entire pattern has to be displayed. If there is no such pattern, this requirement can be ignored.
Eg output:
Right now i am provided withe code to get Requirement 1 with line number. Please help me to get requirement 2.
Last edited by Franklin52; 02-22-2011 at 03:06 AM..
Reason: Please use code tags, thank you
I am trying to consolidate multiple information files (<hostname>.Linux.nfslist) into one file so that I can import it into Excel. I can get the file contents with cat *Linux.nfslist >> nfslist.txt. I need each line prefaced with the hostname. I am unsure how to do this.
--- Post updated at... (5 Replies)
Shell script logic
Hi
I have 2 input files like with file 1 content as (file1)
"BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt
File 2 contents as fle(2)
"BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt
I want to get... (22 Replies)
<tr><td bgcolor=#D7EBAD><b>Instructions :</b></td>
<td>`cat temp.txt`</td></tr>
Hi Experts,
I have an requirement of displaying file contents in HTML mail , for which am using the above approach, Where as the output is kind of not as expected.
If there are 5 lines in the file, in the... (4 Replies)
Hi Friends,
This is the only solution to my task. So, any help is highly appreciated.
I have a file
cat input1.bed
chr1 100 200 abc
chr1 120 300 def
chr1 145 226 ghi
chr2 567 600 unix
Now, I have another file by name
input2.bed (This file is a binary file not readable by the... (7 Replies)
This is Input - starts with Storage Group Name and ends with Shareable and the loop continues all I need is Storage group name and Alu numbers in the below output format requested.
Storage Group Name: abcd
Storage Group UID: 00:00:000:00:0:0:0
HBA/SP Pairs:
HBA UID ... (6 Replies)
Hello,
I am trying to get output from FILE2 that excludes servers from list FILE1. I've tried a for loop with no success. Any ideas how to go about this?
FILE1 contains:
server1
server2
server3
server4
server5
FILE2 contains:
server1:ERROR:user1: error message... (2 Replies)
Hi All,
Need help on this
I have 2 files
one file file1 which has several entries as :
define service{
hostgroup_name !host1,!host5,!host6,.*
service_description check_nrpe
}
define service{
hostgroup_name !host2,!host4,!host6,.*
service_description check_opt
}
another... (2 Replies)
We have 2 file XML files - FILE1.XML and FILE2.xml - we need copy the contents of FILE1.XML and replace in FILE2.xml pattern "<assignedAttributeList></assignedAttributeList>"
FILE1.XML
1. <itemList>
2. <item type="Manufactured">
3. <resourceCode>431048</resourceCode>
4. ... (0 Replies)
Hi,
I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg.
"this is the line1"
"this is the line2"
The yyy.txt with lot of lines. eg:
"This is a test message which contains rubbish information just to fill the page which is of no use. this is... (3 Replies)
I am using AIX and ksh.
I need to display the contents of a file that has a pid (process id). Because the file is open, it doesn't have the line feed or new line, so for some reason if I do this:
`cat $pid` , where $pid is the name of the fully qualified file, it displays
test3.sh: 426110:... (1 Reply)