Computing.Net > Forums > Unix > Help in unix shell please please

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Help in unix shell please please

Reply to Message Icon

Name: kbhatia
Date: April 9, 2008 at 21:32:03 Pacific
OS: WIN X P
CPU/Ram: P4 128
Product: EMACHINE
Comment:

Hi, I am trying to write a shell script that
will take information from two files and combine them into another file using loop structure


file a looks like this
carl monday
bob tuesday
ted sunday

file 2 is like
carl 3
bob 1
ted 2

output has to be

name oncall number
carol monday 3
bob tuesday 1


can anyone help me im so lost



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: April 10, 2008 at 02:05:26 Pacific
Reply:

you might want to see a pseudocode posted here: http://www.daniweb.com/forums/threa...


0

Response Number 2
Name: kbhatia
Date: April 10, 2008 at 05:57:44 Pacific
Reply:

still confised help


0

Response Number 3
Name: nails
Date: April 12, 2008 at 20:32:15 Pacific
Reply:

#!/bin/ksh


# this function reads fileb and checks if the argument passed, $1,
# equals field 1, the return field 2
function get_the_field {

retval=""
while read f1 f2
do
if [[ "$f1" == $1 ]]
then
retval=$f2
break
fi

done < fileb

echo $retval
} # end function

while read f1 f2
do
f3=$(get_the_field $f1)
str="$f1 $f2 $f3"
echo $str
done < filea



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Find un-match in two file... datediff in ksh



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Help in unix shell please please

array in Borne Shell www.computing.net/answers/unix/array-in-borne-shell/3957.html

Unix Shell Script www.computing.net/answers/unix/unix-shell-script/3580.html

reading and writing in UNIX www.computing.net/answers/unix/reading-and-writing-in-unix/1991.html