
03-19-2009
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,378
|
|
Quote:
Originally Posted by vincyoxy
Hi everyone 
I have 2 files - IN & OUT. Example:
IN
A:13:30
B:45:40
.
.
. UNLIMITED
OUT
Z:12:24
Y:20:15
.
.
. UNLIMITED
I want first row of numbers of IN - OUT. Example 13-12 45-20
My code is
|
Please put code inside [code] tags.
csh is not recommended for scripting.Top Ten Reasons not to use the C shell
Csh problems
Csh Programming Considered Harmful
Quote:
|
Code:
set y=1
while ( $y<UNLIMITED )
set in = `awk -F':' '{print $2}' IN |awk '{array[NR]=$0} END {print array[y];}'`
set out = `awk -F':' '{print $2}' OUT |awk '{array[NR]=$0} END {print array[y];}'`
set number = `expr $in - $out`
echo "$number"
@ y = $y + 1
end
|
Code:
cut -d: -f2 in > in.tmp
cut -d: -f2 out > out.tmp
paste -d- in.tmp out.tmp
rm in.tmp out.tmp
|