The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-02-2006
alexcol alexcol is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 31
Unhappy script the output with awk

Please i need your help.

i made this script with awk, this scripts count and list a pattern for each directory in the output as shown. but not as desired. i want the output will be listed in a tabular way, using awk:

cuenta_cdrs()
{
for dir in *
do
cd $dir
for file in *
do
if [ -f $file ]
then
cat listacdrs|awk '
BEGIN {print "dia", "\t", "Cantidad"}
$1 == prev {totaldia+=1}
$1 != prev {print prev,totaldia;totaldia=1;prev=$1;filas=filas+1}'
fi
done
cd ..
done
}

OUTPUT
dia Cantidad

01/09/2006 1275
02/08/2006 1285
03/08/2006 1310
04/08/2006 1300
05/08/2006 1415
dia Cantidad

01/09/2006 1275
02/08/2006 1285
03/08/2006 1310
04/08/2006 1300
05/08/2006 1415
06/08/2006 1265
dia Cantidad

01/09/2006 1275
02/08/2006 1285

But i want the output to be this way:

OUTPUT DESIRED
dia Cantidad dia cantidad

01/09/2006 1275 01/09/2006 1275
02/08/2006 1285 02/08/2006 1285
03/08/2006 1310 03/08/2006 1310
04/08/2006 1300 04/08/2006 1300
05/08/2006 1415 05/08/2006 1415

Thanks