08-23-2008
Awk help needed..
I have to add number in column 1 by month.
1531 Feb 1 2007 pgaps_p007_27909.trc
1529 Feb 1 2007 pgaps_p006_27907.trc
1533 Feb 1 2007 pgaps_p005_27905.trc
635 Apr 7 2007 pgaps_smon_2347.trc
634 Apr 7 2007 pgaps_lgwr_2343.trc
634 Apr 8 2007 pgaps_lgwr_2311.trc
613 Apr 10 2007 pgaps_p004_402.trc
615 Apr 10 2007 pgaps_p002_7500.trc
698 May 2 2007 pgaps_smon_2339.trc
634 May 5 2007 pgaps_lgwr_2335.trc
656 Mar 1 2007 pgaps_smon_8006.trc
634 Mar 3 2007 pgaps_lgwr_8002.trc
634 Mar 4 2007 pgaps_lgwr_2383.trc
641 Mar 8 2007 pgaps_qmn0_20351.trc
Output should be :
Feb 4593
Apr 3131
May 3897
When I run below awk command I am not getting desired output.
ls -ltr |awk 'BEGIN { OFS = "\t"; ORS = "\n\n" } { print $1, $2, $3, $4 }'| awk '{tot=tot+$1}END{print tot}'
Any help would be greatly appreciated.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to write a script that will parse out the e-mail address of a person from the name of a file in a directory.
Example:
filename is:
/home/myname/first.middle.last@email.com.xls
I want to extract just the email address and mail the file to that address.
I want to send the... (6 Replies)
Discussion started by: Drenhead
6 Replies
2. Shell Programming and Scripting
How do I alter this command so that it prints only the second comma delimited field from line number 3? Secondly, how do you redirect the output to a variable called TEST?
Thanks
(cat BATCH007.TXT | awk 'BEGIN { FS = "," } ; {print $2 }') (5 Replies)
Discussion started by: ddurden7
5 Replies
3. Shell Programming and Scripting
Hi ,
i have a file a.txt like this:
far
near
veryfar
toonear
typeset var1=veryfar
to extract the text between two strings i use the following command :
awk '/far/,$veryfar/' a.txt
its not working
can nyone tell pls whats wrong in it ?
i doubt can we use variable in awk like this... (3 Replies)
Discussion started by: santosh1234
3 Replies
4. UNIX for Dummies Questions & Answers
I have a log file monitor script that checks through a log file for a string. I use awk to search the log file, starting at the last checked line, for the specified string and then output the count and the last row number checked. The part of the script that does all the work is here:
set --... (6 Replies)
Discussion started by: mglenney
6 Replies
5. Shell Programming and Scripting
hi,
I have input file woth records as shown below
OCSMRC_OK,7057348733,+0.00,0,18/05/2010 23:42:19,BellMobility,302610000918553,0006056099,B30,686505,686505,OCS_MRC,+49.14,0,0
,0,0,
OCSPPKB_NOK,4163460120,+1.25,0,18/05/2010... (4 Replies)
Discussion started by: raghavendra.cse
4 Replies
6. UNIX for Dummies Questions & Answers
Dear all,
I am new to use unix. I run the following command and got the error. Anyone knows how should I modify the command. Thanks a lot!
$
for chr in 'seq 1 23';
do
awk 'BEGIN {print "T","pheno";}{print "M",$2}' out_${chr}.map > dat_${chr}.dat;
done
error message:... (2 Replies)
Discussion started by: forevertl
2 Replies
7. Shell Programming and Scripting
Hi,
i have input records as shown below.
4097,Probe3,G10,255,05/17/2011 12:44:03:185,NULL,05/17/2011 12:39:03:180,05/17/2011... (1 Reply)
Discussion started by: raghavendra.nsn
1 Replies
8. Shell Programming and Scripting
Hi Experts,
I have a file (file 1) with several columns and I need to create 2 files based on the data of 20th column of file 1.
Criteria 1 : If the 20th field of file1 is empty , copy the entire records to file 2.
I am successfully able to do this with the following awk code :
awk... (2 Replies)
Discussion started by: nua7
2 Replies
9. Shell Programming and Scripting
Hi Everyone,
i have following in my file
1
2
3
4
5
6
.
.
100
and now i want the output as
1 4 7 ..........so on..............97 100 (10 Replies)
Discussion started by: zozoo
10 Replies
10. Shell Programming and Scripting
Hi..
have a file as below, appreciate if someone can help on this
143|500| 10| 23353 22131 23355 23354 23358 23352 23357 23350 23349 23351| RAID5
213|1008| 9| 22419 22412 221 22413 22414 22416 22417 22415 22418| RAID6
1088|500| 5| 22243 22240 22244 22242 22241| RAID5
322|1200| 12|... (6 Replies)
Discussion started by: richard0@rediff
6 Replies
LEARN ABOUT DEBIAN
cdk_draw
cdk_draw(3) Library Functions Manual cdk_draw(3)
NAME
cdk_draw - Cdk Drawing Functions
SYNOPSIS
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
void boxWindow (
WINDOW *window,
chtype attr);
void attrbox ( WINDOW *win,
chtype tlc,
chtype trc,
chtype blc,
chtype brc,
chtype horz,
chtype vert,
chtype attr);
void drawObjBox (
WINDOW *win,
CDKOBJS *object);
void drawLine (
WINDOW *window,
int startx,
int starty,
int endx,
int endy,
chtype line);
void drawShadow (
WINDOW *shadowWin);
void writeBlanks (
WINDOW *window,
int xpos,
int ypos,
int align,
int start,
int end);
void writeChar (
WINDOW *window,
int xpos,
int ypos,
char *string,
int align,
int start,
int end);
void writeCharAttrib (
WINDOW *window,
int xpos,
int ypos,
char *string,
chtype attr,
int align,
int start,
int end);
void writeChtype (
WINDOW *window,
int xpos,
int ypos,
chtype *string,
int align,
int start,
int end);
void writeChtypeAttrib (
WINDOW *window,
int xpos,
int ypos,
chtype *string,
chtype attr,
int align,
int start,
int end);
DESCRIPTION
These functions perform useful drawing and attribute operations.
AVAILABLE FUNCTIONS
boxWindow
draw a box with on the window win. Like attrbox, this function ORs attr with each character as it draws the box.
attrbox
draw a box with on the window win letting the caller define each element of the box.
The parameters tlc, trc, blc, brc are used for the top-left, top-right, bottom-left and bottom-right corners respectively. The param-
eters horz and vert are used for the horizontal and vertical sides of the box. Any of these parameters may be zero. In that case,
the function skips the corresponding element of the box.
The function ORs attr with each character as it draws the box.
drawObjBox
Draw a box around the given window win using the object's defined line-drawing characters.
drawLine
draw a line on the given window.
The parameters starty, startx are the starting coordinates. The parameters endy, endx are the ending coordinates. The function
writes the data in line to each coordinate in that range including the start/end coordinates.
The function handles lines other than vertical or horizontal, but normally it is used for that, e.g., with line set to ACS_HLINE or
ACS_VLINE.
drawShadow
draw a shadow on the right and bottom edges of a window.
writeBlanks
write a string of blanks, using writeChar. The parameters are passed to writeChar as is. There is no corresponding writeBlanksAttrib
function.
writeChar
writes out a char * string without adding attributes. The parameters are passed to writeCharAttrib as is.
writeCharAttrib
writes out a char * string with the given attributes added. The string is written to the given window, using its relative screen
coordinates ypos and xpos. Compare with writeChtypeAttrib, which writes a chtype * string.
The function ORs the attribute attr with each item from the string. For instance, it may be A_BOLD. The align parameter controls
whether it is written horizontally (HORIZONTAL) or vertically (VERTICAL).
Finally, only a subset of the string is written, i.e., from indices start to end.
writeChtype
writes out a chtype * string without adding attributes. The parameters are passed to writeChtypeAttrib as is.
writeChtypeAttrib
writes out a chtype * string with the given attributes added. The string is written to the given window, using its relative screen
coordinates ypos and xpos. You would normally construct the string from a char * string using char2Chtype (3).
The function ORs the attribute attr with each item from the string. For instance, it may be A_BOLD. The align parameter controls
whether it is written horizontally (HORIZONTAL) or vertically (VERTICAL).
Finally, only a subset of the string is written, i.e., from indices start to end.
SEE ALSO
cdk(3), cdk_util(3)
cdk_draw(3)