[urgent need help] about script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [urgent need help] about script
# 1  
Old 12-21-2006
Error [urgent need help] about script

hi experts,

i'm new on scripting on solaris 8 sparc, need some advices. i have some data in a file like :

20061221 163826.485 20061221 163925.144 058.659 6123456789012 00000E8A 047 08 002 465 00010022 510105642138069
20061221 163915.163 20061221 163925.336 010.173 6123456789012 00000F4F 037 02 002 999 00010022 510103242202784
20061221 163852.363 20061221 163925.549 033.186 6123456789012 00000EED 040 06 002 999 00010022 510105832049518
20061221 163803.035 20061221 163925.708 082.673 6123456789012 00000E26 010 08 002 800 00010022 510105732551708
20061221 163921.293 20061221 163925.787 004.494 6123456789012 00000F6C 039 02 002 999 00008001 510105642169788
20061221 163650.185 20061221 163926.027 155.842 6123456789012 00000D16 051 08 002 465 00008001 510105732672986
20061221 163923.325 20061221 163926.381 003.056 6123456789012 00000F75 062 02 002 123 00008001 510103342614669

example of the data :

20061221 163923.325 20061221 163926.381 003.056 6123456789012 00000F75 062 02 002 123 00008001 510103342614669

underline is shortcode and bold is causes code

the filename is in date format like "2006122001.TDR" and the file generated each hour like 2006122002.TDR,2006122003.TDR,etc. the file log found at /log/TDR/

i want to check into the file (e.g. 2006122000.TDR) line by line and get how much shortcode having causes code "00008001" and generate it into the the file (e.g. 2006122000.log) each hour and count per shortcode how much each short code having causes code "00008001".

how to create some script to to the task?

please advices...

thank you so much

wu
# 2  
Old 12-21-2006
Code:
awk '$12 == "00008001" { cnt++;cs_cd[$11] } END { print "Count:"cnt;for(cd in cs_cd) print cd }  ' file

# 3  
Old 12-21-2006
Slight amendment to print the count per type

Code:
awk '$12 == "00008001" { 
    cnt++;cs_cd[$11]++ 
} END { 
    printf "Total Count: %s", cnt
    for(cd in cs_cd) {
        printf "%s: %s\n", cd, cs_cd[cd] 
    }
} ' file

# 4  
Old 12-21-2006
hi anbu & reborg,

thank you so much for the help.

how to write to file all line and sorted which having causes code "00008001" and shortcode "..." ?

i mean full line (e.g. 20061221 163921.293 20061221 163925.787 004.494 6123456789012 00000F6C 039 02 002 999 00008001 510105642169788)

thank you so much

please advices


wu
# 5  
Old 12-22-2006
Code:
awk '$12 == "00008001" ' file | sort -t" " -kn11 > newfile

If you want the sorting to be in descending way then
Code:
awk '$12 == "00008001" ' file | sort -t" " -knr11 > newfile

# 6  
Old 12-26-2006
hi anbu,

thank you so much for the help.

fyi, that the log file will logged every hour per day for example : 2006122000.log,2006122001.log,etc

note : 2006122000.log (yyyymmddhh.log)

and will saved in directory like /export/home/log/200612

how to make a script running in background to count how much each shortcode having causes code "00008001" and can logged it the info into file.txt ?

note :the script can read the log file each hour and count it

please advices


thank you so much


wu



Quote:
Originally Posted by anbu23
Code:
awk '$12 == "00008001" ' file | sort -t" " -kn11 > newfile

If you want the sorting to be in descending way then
Code:
awk '$12 == "00008001" ' file | sort -t" " -knr11 > newfile

# 7  
Old 12-26-2006
use & to run the command in background like :-

temp.sh &
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

3. Shell Programming and Scripting

I want an urgent script

Hi I want a script which reads a file and ftped the content of that file into another server.The file saved in new location as filename.date (3 Replies)
Discussion started by: Renjesh
3 Replies

4. Shell Programming and Scripting

sed script help urgent

Collegues I am dealing with raw text files which is extracted from web pages. I have to find sentances which contains more than 99 words and have to put a "." after the 99th or 98 th word . Is there any possiblity to it in sed or awk With regards Jaganadh.H (5 Replies)
Discussion started by: jaganadh
5 Replies

5. UNIX for Dummies Questions & Answers

Urgent Script Needed

I need shell script code for the following 1. Read syscat.columns after connecting to DB2 using SQL cursor 2. Read the output of the previous SQL command in the shell script 3. Perform insertions and deletions in the output of step 1 Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

6. Shell Programming and Scripting

[urgent need help] unix script....

hi experts, i'm new in scripting unix i have some problem with my script below is shown my script : #!/bin/sh BASEDIR=/export/home/mapadm BINDIR=$BASEDIR/bin LOGDIR=$BASEDIR/log TDRDIR=$LOGDIR/TDR BACKUPDIR=/data/log export BASEDIR BINDIR LOGDIR TDRDIR BACKUPDIR YEAR=`date '+%Y'`... (21 Replies)
Discussion started by: bucci
21 Replies

7. Shell Programming and Scripting

Script - Urgent Help

Hi guys, i really need some urgent help on a few things I'm an extreme unix novice, Can you guys please help me with a couple of questions. I am in no way asking anyone to do it for me, but i am really asking for some extremely in depth help. I know alot of this is very second nature to... (4 Replies)
Discussion started by: troy86
4 Replies

8. Shell Programming and Scripting

Need a Script(Urgent)

sdfggggggggggggggggggggg (7 Replies)
Discussion started by: udayben
7 Replies
Login or Register to Ask a Question