Sponsored Content
Top Forums Shell Programming and Scripting gzcat into awk and then change FILENAME and process new FILENAME Post 302208010 by timj123 on Sunday 22nd of June 2008 02:24:32 PM
Old 06-22-2008
Thanks guys, I have learned so much from the both of you. I am still having issues that I can't figure out, here is the script:
Code:
/usr/bin/gzcat $file | /usr/xpg4/bin/awk '

BEGIN {
print "headers go here"
}


NR == 3 { print $2,$3"  --  "$4,$5 ; print "" ; next }

/^dise / {
        dipce = substr($2,4,1) * 1000 ; next
           }
/^LC/ {
        lec = substr($0,3,3) + dipce
        f++
        s = ""
        for ( i in arr ) { delete arr[i] }
        }
	   f {
              if ( $1 == "RRAC" ) {
                s++
                 }
                if ( s ) {
                    if ( $1 == "tsec" ) {
                       lectsec = $2 * 1
                       }
                    if ( $1 == "VAR" ) {
                        car[$2 * 1]+=$8
                        lecCar = $2 * 1
                        c[lec,lectsec,BCar] = 0
                        }
                     c[lec,lectsec,BCar]++
                     if ( c[lec,lectsec,BCar] == 8 ) {
                        car[BCar]+=$8
                        tst[lec"-"BCar]=sprintf("%5.2f",car[BCar] / 12)
                        }
                    }
                if ( $1 == "RRAC-L" ) {
                        f = "" ; next
                   }
                   }


###Here I want to change FILENAME to "'"$ofile"'" ###
#####################################################

{
while (( getline < "'"$ofile"'" ) > 0 ) {
FS = "\;" ; print $1,$3,$4 ; next }
}
#####################################################
END {
for ( i in tst ) { print i,tst[i] }

    } '

/usr/bin/rm $ifile
/usr/bin/rm $ofile

When I change FS it also changes the output of the following:
Code:
for ( i in tst ) { print i,tst[i] }

I can't figure this out??? Why does this change the output of the array?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change new filename with date ??

Hi all, I am newbie and hope that you can help me to rename a file If I have a file name Perform.01222006.12345.Log now I would like to backup another file with another name like perform-20060112.dat This is a flat file, and I want to collect some field, then put it in a new file from... (9 Replies)
Discussion started by: sabercats
9 Replies

2. UNIX for Dummies Questions & Answers

Change multiple filename formats with WHILE

Hi All, I'm trying to run a simple shell program to change all the files named *.cvs to *.txt. I am trying to use WHILE and this is what I have so far: This changes the first file from *.cvs to *.txt, but it is not cycling through the other files. My suspicion is that I don't have the... (5 Replies)
Discussion started by: ScKaSx
5 Replies

3. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

4. Shell Programming and Scripting

Change the filename

I have 100 files in a directory with a.1 a.2 a.3 a.4 How do i remove a. and i need the file names as 1 2 3 4 please help (2 Replies)
Discussion started by: srichunduru
2 Replies

5. Shell Programming and Scripting

filename change with awk needed

Hi, i have files which contains list of csv file names say temp.txt contains below like data Dns_bangalore_08172011.093033.1139.csv Dns_bangalore_08172011.093133.1139.csv now i want to insert some string before .csv in the filename say i want to insert string _sim1 beofre .csv... (3 Replies)
Discussion started by: raghavendra.nsn
3 Replies

6. Shell Programming and Scripting

Change the filename variable value

Hi guys, I have a variable where i am storing the filename (with full path). I just need the value before ".txt". But instead of getting the filename i am getting the contents of the filename. FileName=/appl/data/Input/US/Test.txt a=`awk -F"." '{print $1}' ${FileName}` echo $a... (3 Replies)
Discussion started by: mac4rfree
3 Replies

7. UNIX for Dummies Questions & Answers

How to change date in a filename?

Hi i want to list files based on date and change the date alone in the files in a directory abc20120101.txt xyzxyxz20120101.txt ccc20120201.txt ddd20120301.txt In the above i want to select only files having date 20120101 and rename the date for those files like below abc20111231.txt... (3 Replies)
Discussion started by: Dewdrop
3 Replies

8. Shell Programming and Scripting

Change filename - increment digit by 60

I have a bunch of files, they have spaces! I am working in windows 7, but I am hoping I could install and use cygwin or some other unix platform to rename my files (suggestions welcome). The files are named: Wind Attn Vol - 474.wrl Wind Attn Vol - 475.wrl Wind Attn Vol - 476.wrl etc.. I... (10 Replies)
Discussion started by: d_sai_kumar
10 Replies

9. UNIX for Dummies Questions & Answers

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv OTP_UFSC_20120530000000_prom.csv... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

10. Programming

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My code: if then set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator"\ "pam_account"; for i in 1 2 3 4 5 6 7 8;... (0 Replies)
Discussion started by: aealexanderraj
0 Replies
car(1)								   GNU Telephony							    car(1)

NAME
car - crytographic archiver. SYNOPSIS
car [options] [paths...] car --decode [.carfile] DESCRIPTION
Creates and decodes portable cross-platform crytographic archives. An archive can be a collection of files, or an in-stream message that is piped. Output can be to a binary .car file, or ascified text. A symetric cipher is used, and the passhrase is hashed to form a key. OPTIONS
--cipher=name Specify symetric cipher. By default 256 bit aes is used. --decrypt Specify decryption operation on an existing car stream or file. If no file is specified, stdin is used. --digest=name Specify name of digest algorithm. By default sha will be used. --follow Dereference and follow symlinks. Otherwise they are ignored. --output=filename Specify output file for a new archive. By default stdout is used. --overwrite Always overwrite existing files without prompting. --quiet Non-interactive and no status output. --recursive If argument is a directory, recursively scan directory and any subdirectory contents as arguments. --help Outputs help screen for the user. AUTHOR
car was written by David Sugar <dyfet@gnutelephony.org>. REPORTING BUGS
Report bugs to bug-commoncpp@gnu.org. COPYRIGHT
Copyright (C) 2010 David Sugar, Tycho Softworks. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. GNU uCommon January 2010 car(1)
All times are GMT -4. The time now is 01:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy