The UNIX Forums
"Join the Network of UNIX System Users"


 
darzuaga
Newbie
Rank: 1



UID 106
Digest Posts 0
Credits 0
Posts 50
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at May 25, 2007 03:26 AM  Profile | P.M. 
what the logic



what the logic



i have a text file which contain some text like

we|are|one|only
i|am|learning|c++



the input from stdout will be

input1 we
input2 one

it should search in the file where this two strings are and then give the
output :

output1 are
output2 only

similarly

input1 i
input2 learning

output1 am
output2 c++

based up on the input searched we get the output fileds.| are the delimirters


Top
eukhost
Newbie
Rank: 1



UID 138
Digest Posts 0
Credits 0
Posts 19
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at May 25, 2007 03:27 AM  Profile | P.M. 
please read rules and regulation of the forum.

your questions seems to be a homework assignment. try to figure out yourself.
Top
ahkip
Newbie
Rank: 1



UID 41
Digest Posts 0
Credits 0
Posts 14
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at May 25, 2007 03:27 AM  Profile | P.M. 
hi,

this is just a vague sample of the above req mentioned.
not thoroughly tested.

echo "give the first input."
read input1

echo "give the second input."
read input2

line=`grep $input1 <filename> | grep $input2 <filename>`
output1=`echo $line | cut -f1 -d"|"`
if [ $output1 = $input1 ]
then
output1=`echo $line | cut -f2 -d"|"`
fi
output2=`echo $line | cut -f3 -d"|"`
if [ $output2 = $input2 ]
then
output2=`echo $line | cut -f4 -d"|"`
fi

echo "output1: $output1"
echo "output2: $output2"


please let me know if my understanding and proceeding with the req was correct or not.
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:25 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005549 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP