Computing.Net > Forums > Unix > is this simple task ? please help.

is this simple task ? please help.

Reply to Message Icon

Original Message
Name: Marian
Date: April 22, 2002 at 12:46:37 Pacific
Subject: is this simple task ? please help.
Comment:

I wonder if anybody can help with this simple task. I need to make it work in AIX version of Unix.

I'd like to read from file 1, from let's say position 20-36 and search for the string in file 2. If the string doesn't exist, write the output to a file.

So the script would work something like this. I enter the names of the file 1 and file 2.The script will take the string from position e.g.20 to 36 line by line and then looks for the string in the file 2. If it finds the match it will write output let's say in file 3, if it doesn't - it'll write the unmatched strings in file 4.

Is it possible to write a simple command script that will work like that ?

Thanks in advance for you soon reply.

p.s. any other solutions, recommendations and ideas are welcome !

Marian


Report Offensive Message For Removal


Response Number 1
Name: Don Arnett
Date: April 23, 2002 at 08:54:45 Pacific
Subject: is this simple task ? please help.
Reply: (edit)

I'm sure that it's possible, tho it depends upon your definition of simple. What's the purpose of this program? Sometimes knowing the use of the program helps in understanding the problem.


Report Offensive Follow Up For Removal

Response Number 2
Name: marian
Date: April 23, 2002 at 21:59:48 Pacific
Subject: is this simple task ? please help.
Reply: (edit)

i need to look for a certain string in file 1 and then search for the string if it exists in file 2. I search for identification number that exists in file 1 and if it exists in file 2 too. And it doesn't matter what the actual position of the id number is. Will you help ?


Report Offensive Follow Up For Removal

Response Number 3
Name: James Boothe
Date: April 26, 2002 at 16:25:21 Pacific
Subject: is this simple task ? please help.
Reply: (edit)

This script will write entire qualifying lines to file3, and if no lines found for a given identification number, will append that number to file4:

#!/bin/sh

file1=$1
file2=$2
file3=marian.found
file4=marian.notfound

rm -f $file3 $file4 2> /dev/null

cat $file1 | while read line
do
idnbr=`echo $line | cut -c20-36`
if grep "$idnbr" $file2 >> $file3 ; then
:
else
echo "$idnbr" >> $file4
fi
done

exit 0


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: is this simple task ? please help.

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software