using awk to count no of records based on conditions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using awk to count no of records based on conditions
# 8  
Old 06-07-2009
With this awk code you can convert the format "2009 6 6" to "06-Jun-2009", usage:

Code:
awk -v var="2009 6 6" '
BEGIN{
  split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")
  for (i=1; i<=12; i++) mdigit[month[i]]=i
  split(var,d)
  m=int(d[3])
  printf("%02d-%s-%s\n",d[2],month[m],d[1])
}'

You should be able now to use it to fit your code.
# 9  
Old 06-08-2009
Y can't u put a simple condition in control file like this to convert the data while loading :

Code:
into table sample
fields terminated by "," optionally enclosed by '"'
(i , j, k  "to_date(:k, 'DD/MM/YYYY')" )

# 10  
Old 06-08-2009
hi

i found the answer in the forum itself

https://www.unix.com/shell-programmin...ious-date.html

b=`TZ=CST+24 date +%y%m%d`

thats cool....

and one more thing is required for that i will start a new thread...

thanks buddies..

Aemu
# 11  
Old 06-09-2009
hi

i put the script in crontab and when it runs, produces the following output
Code:
Your "cron" job on lessrv7
/space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/totalcdrcount > totalcdrcount.txt 

produced the following output:

input file "20090608*"

cron entry is
Code:
40 11 * * * /space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/totalcdrcount > totalcdrcount.txt

if i run the script from that folder it gives the desired output
like

Code:
 ./totalcdrcount > totalcdrcount.txt


what could be the issue?
# 12  
Old 06-09-2009
Try to use the full path for the output file:

Code:
/space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/totalcdrcount > /space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/totalcdrcount.txt

# 13  
Old 06-09-2009
HI

am getting the same kind of eror

Code:
Your "cron" job on lessrv7
/space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/totalcdrcount >/space/canvas/home/lbs/current/internalcdrba
ckup/LES_CDR_Configuration/0/totalcdrcount.txt 

produced the following output:

input file "20090608*"

# 14  
Old 06-14-2009
hi

this issue still persist for me...cron gives the output as
Quote:
Your "cron" job on lessrv1
/space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/MSISDNcdrCount > /space/canvas/home/lbs/current/internalcdrbackup/LES_CDR_Configuration/0/MSISDNcdrCount.txt

produced the following output:

input file "20090613*"
am opening a new thread for this...

please help me out
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to assign points to variables based on conditions and update specific field

I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points to variable, but made an attempt at an awk... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Awk/sed/cut to filter out records from a file based on criteria

I have two files and would need to filter out records based on certain criteria, these column are of variable lengths, but the lengths are uniform throughout all the records of the file. I have shown a sample of three records below. Line 1-9 is the item number "0227546_1" in the case of the first... (15 Replies)
Discussion started by: MIA651
15 Replies

3. Shell Programming and Scripting

awk to update file based on 5 conditions

I am trying to use awk to update the below tab-delimited file based on 5 different rules/conditions. The final output is also tab-delimited and each line in the file will meet one of the conditions. My attemp is below as well though I am not very confident in it. Thank you :). Condition 1: The... (10 Replies)
Discussion started by: cmccabe
10 Replies

4. Shell Programming and Scripting

awk to filter file based on seperate conditions

The below awk will filter a list of 30,000 lines in the tab-delimited file. What I am having trouble with is adding a condition to SVTYPE=CNV that will only print that line if CI= must be >.05 . The other condition to add is if SVTYPE=Fusion, then in order to print that line READ_COUNT must... (3 Replies)
Discussion started by: cmccabe
3 Replies

5. Shell Programming and Scripting

count the unique records based on certain columns

Hi everyone, I have a file result.txt with records as following and another file mirna.txt with a list of miRNAs e.g. miR22, miR123, miR13 etc. Gene Transcript miRNA Gar Nm_111233 miR22 Gar Nm_123440 miR22 Gar Nm_129939 miR22 Hel Nm_233900 miR13 Hel ... (6 Replies)
Discussion started by: miclow
6 Replies

6. Shell Programming and Scripting

Extract file records based on some field conditions

Hello Friends, I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited): ColA|ColB|ColC|ColD|ColE|ColF Now for this file, I have to get those records which fulfil the following condition: If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies

7. Shell Programming and Scripting

awk merging files based on 2 complex conditions

1. if the 1st row IDs of input1 (ID1/ID2.....) is equal to any IDNames of input2 print all relevant values together as defined in the output. 2. A bit tricky part is IDno in the output. All we need to do is numbering same kind of letters as 1 (aa of ID1) and different letters as 2 (ab... (4 Replies)
Discussion started by: ruby_sgp
4 Replies

8. Shell Programming and Scripting

Awk to Count Records with not null

Hi, I have a pipe seperated file I want to write a code to display count of lines that have 20th field not null. nawk -F"|" '{if ($20!="") print NR,$20}' xyz..txt This displays records with 20th field also null. I would like output as: (4 Replies)
Discussion started by: pinnacle
4 Replies

9. Shell Programming and Scripting

Record count based on a keyword in the records

Hi, Am having files with many records, i need to count and display the number of records based on the keyword in one of the column of the records. for e.g THE FILE CONTAINS TWO RECORDS LIKE. 200903031143150 0 1236060795054357lessrv1 BSNLSERVICE1 BSNLSERVICE1 ... (4 Replies)
Discussion started by: aemunathan
4 Replies

10. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies
Login or Register to Ask a Question