Sponsored Content
Full Discussion: script the output with awk
Top Forums Shell Programming and Scripting script the output with awk Post 302091315 by alexcol on Monday 2nd of October 2006 12:53:46 AM
Old 10-02-2006
Data 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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Format output using awk in script.

Guys, I have a script which hits the database and pulls the information that I need into files. Now I want to format these files to make them easy to read. The sample format of the file will be like.... <Start_of_File> Header1 .....xsdfsfa...adfa...... Header2 ....afefas .aefaefsdf...... (8 Replies)
Discussion started by: bperl
8 Replies

2. Shell Programming and Scripting

Colon in awk script output

I'm using AIX 5.3 and running a awk replace to modify data as follows: echo 1234: 1234 123 123 444 555 666 7777 | awk '/^:/{split($2,N);n=N} {n=$1} {sub(n,n+10000000)}1' 10001234 1234 123 123 444 555 666 7777 dumb question.. how do I get the colon back in, so it outputs 10001234: 1234... (4 Replies)
Discussion started by: say170
4 Replies

3. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

4. Shell Programming and Scripting

How to get fields and get output with awk or shell script.?

I have a flat file A.txt with field seperate by a pipe 2012/11/13 20:06:11 | 284:hawk pid=014268 opened Locations 12, 13, 14, 15 for /home/hawk_t112/t112/macteam/qt/NET12/full_ddr3_2X_FV_4BD_1.qt/dbFiles/t112.proto|2012/11/14 15:19:26 | still running |norway|norway 2012/11/14 12:53:51 | ... (6 Replies)
Discussion started by: sabercats
6 Replies

5. Shell Programming and Scripting

awk script to search output for a value and print

GOODNUMBERS="1 2 3 4 5 6 3 3 34 34 5 66 12" BADNUMBERS="7 3 12 5 66" for eachnum in `echo ${GOODNUMBERS}` do echo ${BADNUMBERS} | gawk -v threshold=${eachnum} '$1 != threshold' done what im trying to do with the above is, i want to print numbers that are in the GOODNUMBERS... (10 Replies)
Discussion started by: SkySmart
10 Replies

6. Shell Programming and Scripting

awk Script to format output

Hi all, I'm fairly new to this and learning along the way, so bare with me... I'm trying to format the output from a script to be more read-friendly. The output contains more servers and more processes but for as example it will do: Server: Test1 ... (4 Replies)
Discussion started by: Bobsonm
4 Replies

7. Shell Programming and Scripting

awk script not producing output

Hi, I have a text file with some thousands of rows of the following kind (this will be referred to as the inputFileWithColorsAndNumbers.txt): Blue 6 Red 4 Blue 3 Yellow 4 Red 7 Colors in the left column and a number in the right one for each line. I want to run an awk... (5 Replies)
Discussion started by: Zooma
5 Replies

8. UNIX for Dummies Questions & Answers

Combine Both Output from the awk Script

Hi, Is there anyway to combine output from the awk scripting. file01.txt: AUE_CHMOD AUE_CHOWN AUE_CHROOT AUE_CONNECT AUE_ACCEPT AUE_FCHOWN AUE_FCHMOD AUE_SETREUID AUE_SETREGID AUE_FCHROOT AUE_PFEXEC AUE_SETUID AUE_NICE AUE_SETGID (9 Replies)
Discussion started by: alvinoo
9 Replies

9. UNIX for Beginners Questions & Answers

awk Script Output Help

My code is listed below, I'm trying to figure out what the problem is and what I can do to fix it. The output i'm getting is: Name Low High Average 0 0 0.00 The correct output I want is the name of the Assignment, the lowest score and highest score obtained, and the Average Score... (10 Replies)
Discussion started by: Marquez3105
10 Replies

10. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies
apertium-reodt(1)														 apertium-reodt(1)

NAME
apertium-reodt - This application is part of ( apertium ) This tool is part of the apertium open-source machine translation toolbox: http://www.apertium.org. SYNOPSIS
apertium-reodt [ <input file> [ <output file> ] ] DESCRIPTION
apertium-reodt is an ODT format processor. It restores the original ODT formatting the text had before being passed through the apertium- desodt deformatter. OPTIONS
-h, --help Display this help. SEE ALSO
apertium-retxt(1), apertium-rertf(1), lt-proc(1), apertium-translator(1) apertium(1). BUGS
Lots of...lurking in the dark and waiting for you! AUTHOR
Copyright (c) 2005, 2006 Universitat d'Alacant / Universidad de Alicante. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. 2006-03-21 apertium-reodt(1)
All times are GMT -4. The time now is 05:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy