08-05-2008
line-by-line matching script
First post by a newbie. Pls help....
#!/bin/ksh
OBJECT_LIST=/export/home/russellc/infile99.lst
OUTPUT_FILE=/export/home/russellc/outfile99.lst
cd /export/home/russellc/
for mystuff_obj in `cat $OBJECT_LIST`
do
find . -name "scanfile99.txt" | xargs grep -in $mystuff_obj >> $OUTPUT_FILE
done
Contents of /export/home/russellc/infile99.lst
--------------------------------------------
ABCD
EFGH
IJKL
MNOP
Contents of /export/home/russellc/scanfile99.txt
----------------------------------------------
I have ABCD in my mind
She thinks I think WXYZ
Everybody thinks I think EFGH
Nobody thinks I think MNOP
Contents of /export/home/russellc/outfile99.lst
---------------------------------------------
1:I have ABCD in my mind
3:Everybody thinks I think EFGH
4:Nobody thinks I think MNOP
In short, the script result (outfile99.lst) shows the matched lines from scanfile99.txt.
How can I make the script output the matched lines from infile99.lst instead?
Ex.,
ABCD
EFGH
MNOP
Thanks in advance!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hello experts,
I have a file: File1 Sample Test1
This is a Test
Sample Test2
Another Test
Final Test3
A final Test
I can use sed to delete the line with specific text
ie: sed '/Test2/d' File1.txt > File2.txt
How can I delete the line with the matching text and the line immediately... (6 Replies)
Discussion started by: orahi001
6 Replies
2. Shell Programming and Scripting
How do transform only the first line that matches my regex? I've tried q but it just quit my script in the middle. (9 Replies)
Discussion started by: yogert909
9 Replies
3. Shell Programming and Scripting
Hi
I am not the best scripter in the world and have run into a issue which you might be able to guide me on...
I have two files.
File1 :
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
File2:
C345,... (5 Replies)
Discussion started by: luckycharm
5 Replies
4. Shell Programming and Scripting
Hi All,
I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies
5. Shell Programming and Scripting
I have a LOG file which looks like this
Import started at: Mon Jul 23 02:13:01 EDT 2012
Initialization completed in 2.146 seconds.
--------------------------------------------------------------------------------
--
Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies
6. Shell Programming and Scripting
Hi, I have text file:
Name: xyz
Gender: M
Address: "120_B_C; ksilskdj; lsudlfw"
Zip: 20392
Name: KLM
Gender: F
Address: "65_D_F; wnmlsi;lsuod;,...."
Zip:90233I want to insert 2 new lines before the 'Address: ' line deriving value from this Address line value
The Address value in quotes... (1 Reply)
Discussion started by: ysrini
1 Replies
7. Shell Programming and Scripting
Hi,
I want to achieve something similar to what described in another post:
The difference is I want to add the line if the pattern is not found.
File 1:
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
... (11 Replies)
Discussion started by: jyu3
11 Replies
8. Shell Programming and Scripting
HI
Can any one guide me how to achieve this task. I have 2 files
env.txt
#Configuration.Properties values
identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register
randon_password_length = 6
attachment_file_path = /pass/temp/attachments/... (1 Reply)
Discussion started by: nikilbr86
1 Replies
9. Shell Programming and Scripting
Hello,
I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies
10. UNIX for Beginners Questions & Answers
Input file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
LEARN ABOUT HPUX
parse_dynamic_clustertoc
parse_dynamic_clustertoc(1M) System Administration Commands parse_dynamic_clustertoc(1M)
NAME
parse_dynamic_clustertoc - parse clustertoc file based on dynamic entries
SYNOPSIS
cdrom/export/exec/sparc.Solaris_2.x/sbin/install.d/parse_dynamic_clustertoc
cdrom/export/exec/i386.Solaris_2.x/sbin/install.d/parse_dynamic_clustertoc
DESCRIPTION
This script parses the clustertoc file before the suninstall(1M) process is run. parse_dynamic_clustertoc is called by a modified syscon-
fig script on the install CD. When parse_dynamic_clustertoc runs, it reads the clustertoc and when it encounters SUNW_CSRMBRIFF lines, it
either checks the platform using the script's builtin function, or calls an external script. The script exits with a 0 if the cluster
entry is included, otherwise it will be ignored. If the cluster entry is to be included, the SUNW_CSRMBRIFF =(test test_arg)cluster line
is converted to SUNW_CSRMEMBER =cluster.
EXAMPLES
Example 1: Checking For an SX Framebuffer
The following is an example of a simple external test to check for an SX Framebuffer. The entry in the clustertoc file is shown and fol-
lowing that is the script that must be placed in the install.d/dynamic_test directory.
SUNW_CSRMBRIFF=(smcc.dctoc sx)SUNWCsx
#! /bin/sh
#
# Likewise, this file is expected to live under $(TESTDIR).
#
case "$1"
in
sx) prtconf -p | grep 'SUNW,sx' 1> /dev/null;;
esac
FILES
cdrom/Solaris_2.x/locale/C/.clustertoc.dynamic
Dynamic version of the clustertoc file
cdrom/export/exec/sparc.Solaris_2.x/sbin/install.d/dynamic_test
Directory that contains any additional tests
cdrom/export/exec/i386.Solaris_2.x/sbin/install.d/dynamic_test
Directory that contains any additional tests
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SHWPcdrom (Solaris CD) |
+-----------------------------+-----------------------------+
SEE ALSO
suninstall(1M), clustertoc(4), attributes(5)
SunOS 5.10 6 Sep 1995 parse_dynamic_clustertoc(1M)