Sponsored Content
Full Discussion: Parse a file with awk?
Top Forums Shell Programming and Scripting Parse a file with awk? Post 302545540 by tulf210 on Monday 8th of August 2011 06:18:40 PM
Old 08-08-2011
Parse a file with awk?

Hi guys (and gals).

I need some help. I'm running an IVR purely on Asterisk where I capture the DTMFs. After pulsing each DTMF I have Asterisk write to a file with whatever was dialed (mostly used for record-keeping) and at the end of the survey I write all variables in a single line to a separate file from which I generate reports and the results. I had a problem and for a couple of days this last file has not been getting written, but I have the other (debug) file.

If you look at the debug I have date, time, Question #, a number (unique id per call or call identifier), response, this for each question (12 in total). The one file I get my reports from has date, time, a number, answer 1, answer 2, ..., answer 12.

I need to generate the 'report file' from the 'debug file'. I know it has to be quite simple using awk, but I just can't get there. Any help..., please.... Smilie

Many thanks!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse file using awk and work in awk output

hi guys, i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 this the file raw format: Number of... (6 Replies)
Discussion started by: dagigg
6 Replies

2. Shell Programming and Scripting

AWK - Parse a big file

INPUT SAMPLE Symmetrix ID : 000192601507 Masking View Name : TS00P22_13E_1 Last updated at : 05:10:18 AM on Tue Mar 22,2011 Initiator Group Name : 10000000c960b9cd Host Initiators { WWN : 10000000c960b9cd } Port Group Name :... (8 Replies)
Discussion started by: greycells
8 Replies

3. Shell Programming and Scripting

AWK Command parse a file based on string.

AWK Command parse a file based on string. I am trying to write a shell script to parse a file based on a string and move the content of the file to another file. Here is scenario. File content below Mime-Version: 1.0 Content-Type: multipart/mixed; ... (2 Replies)
Discussion started by: aakishore
2 Replies

4. Shell Programming and Scripting

AWK script to parse a data in a file

Hi Unix gurus.. I have a file which has below data, It has several MQ Queue statistics; QueueName= 'TEST1' CreateDate= '2009-10-30' CreateTime= '13.45.40' QueueType= Predefined QueueDefinitionType= Local QMinDepth= 0 QMaxDepth= 0 QueueName= 'TEST2' CreateDate= '2009-10-30'... (6 Replies)
Discussion started by: dd_psg
6 Replies

5. Shell Programming and Scripting

Parse a file using awk

Hi Experts, I am trying to parse the following file; FILEA a|b|c|c|c|c a|b|d|d|d|d e|f|a|a|a|a e|f|b|b|b|boutput expected: a<TAB>b <TAB><TAB>c<TAB>c<TAB>c<TAB>c<TAB> <TAB><TAB>d<TAB>d<TAB>d<TAB>d<TAB> e<TAB>f <TAB><TAB>a<TAB>a<TAB>a<TAB>a<TAB> <TAB><TAB>b<TAB>b<TAB>b<TAB>b<TAB>*... (7 Replies)
Discussion started by: rajangupta2387
7 Replies

6. Shell Programming and Scripting

Using awk to Parse File

Hi all, I have a file that contains a good hundred of these job definitions below: Job Name Last Start Last End ST Run Pri/Xit ________________________________________________________________ ____________________... (7 Replies)
Discussion started by: atticuss
7 Replies

7. Shell Programming and Scripting

awk to parse html file

Is it possible in awk to parse a webpage (EDAR Gene Sequencing - Genetic Testing Company | The DNA Diagnostic Experts | GeneDx), the source code is attached. <title> EDAR Gene Sequencing <dt>Test Code:</dt> <dd>156 </dd> <dt>Turnaround Time:</dt> <dd>6-8 weeks </dd> ... (4 Replies)
Discussion started by: cmccabe
4 Replies

8. Shell Programming and Scripting

awk or perl to parse file

I have an input file attached that I am trying to parse in tab-delimanted format: The chromosomal variant column contains all the information: parse rules: 1. 4 zeros after the NC_ and the digits before the . 2. digits after the g. repeated twice separated by a tab 3. letter before the > 4.... (10 Replies)
Discussion started by: cmccabe
10 Replies

9. Shell Programming and Scripting

awk parse result that match data from file

i run command that return this result,example : gigabitethernet2/2/4:NotPresent, gigabitethernet2/1/17:UP, gigabitethernet2/1/10:UP, gigabitethernet2/1/5:UP, gigabitethernet2/1/9:UP, gigabitethernet2/1/36:DOWN, gigabitethernet2/1/33:DOWN, gigabitethernet2/1/8:UP,... (19 Replies)
Discussion started by: wanttolearn1
19 Replies

10. Shell Programming and Scripting

How to parse this file using awk and output in CSV format?

My source file looks like this: Cust-Number = "101" Cust-Name="Joe" Cust-Town="London" Cust-hobby="tennis" Cust-purchase="200" Cust-Number = "102" Cust-Name="Mary" Cust-Town="Newyork" Cust-hobby="reading" Cust-purchase="125" Now I want to parse this file (leaving out hobby) and... (10 Replies)
Discussion started by: Balav
10 Replies
asterisk (8)															      asterisk (8)

NAME
asterisk - All-purpose telephony server. SYNOPSIS
asterisk [-BcdfFghiImnpqRtTvVW] [-C file] [-e memory] [-G group] [-L loadaverage] [-M value] [-U user] [-s socket-file] asterisk -r [-v] [-d] [-x command] asterisk -R [-v] [-d] [-x command] DESCRIPTION
asterisk is a full-featured telephony server which provides Private Branch eXchange (PBX), Interactive Voice Response (IVR), Automated Call Distribution (ACD), Voice over IP (VoIP) gatewaying, Conferencing, and a plethora of other telephony applications to a broad range of tele- phony devices including packet voice (SIP, IAX2, MGCP, Skinny, H.323, Unistim) devices (both endpoints and proxies), as well as traditional TDM hardware including T1, E1, ISDN PRI, GR-303, RBS, Loopstart, Groundstart, ISDN BRI and many more. At start, Asterisk reads the /etc/asterisk/asterisk.conf main configuration file and locates the rest of the configuration files from the configuration in that file. The -C option specifies an alternate main configuration file. Virtually all aspects of the operation of aster- isk's configuration files can be found in the sample configuration files. The format for those files is generally beyond the scope of this man page. When running with -c, -r or -R options, Asterisk supplies a powerful command line, including command completion, which may be used to moni- tors its status, perform a variety of administrative actions and even explore the applications that are currently loaded into the system. Asterisk is a trademark of Digium, Inc. OPTIONS
Running Asterisk starts the asterisk daemon (optionally running it in the foreground). However running it with -r or -R connects to an ex- isting Asterisk instance through a remote console. -B Force the background of the terminal to be black, in order for terminal colors to show up properly. Equivalent to forceblackback- ground = yes in asterisk.conf. See also -n and -W. -C file Use file as master configuration file instead of the default, /etc/asterisk/asterisk.conf -c Provide a control console on the calling terminal. The console is similar to the remote console provided by -r. Specifying this op- tion implies -f and will cause asterisk to no longer fork or detach from the controlling terminal. Equivalent to console = yes in asterisk.conf. -d Enable extra debugging statements. This parameter may be used several times, and each increases the debug level. Equivalent to debug = num in asterisk.conf to explicitly set the initian debug level to num. When given at startup, this option also implies -f (no forking). However when connecting to an existing Asterisk instance (-r or -R), it may only increase the debug level. -e memory Limit the generation of new channels when the amount of free memory has decreased to under memory megabytes. Equivalent to minmem- free = memory in asterisk.conf. -f Do not fork or detach from controlling terminal. Overrides any preceding specification of -F on the command line. Equivalent to no- fork = yes in asterisk.conf. See also -c. -F Always fork and detach from controlling terminal. Overrides any preceding specification of -f on the command line. May also be used to prevent -d and -v to imply no forking. Equivalent to alwaysfork = yes in asterisk.conf. -g Remove resource limit on core size, thus forcing Asterisk to dump core in the unlikely event of a segmentation fault or abort sig- nal. NOTE: in some cases this may be incompatible with the -U or -G flags. -G group Run as group group instead of the calling group. NOTE: this requires substantial work to be sure that Asterisk's environment has permission to write the files required for its operation, including logs, its comm socket, the asterisk database, etc. -h Provide brief summary of command line arguments and terminate. -i Prompt user to intialize any encrypted private keys for IAX2 secure authentication during startup. -I Enable internal timing if DAHDI timing is available. The default behaviour is that outbound packets are phase locked to inbound packets. Enabling this switch causes them to be locked to the internal DAHDI timer instead. -L loadaverage Limits the maximum load average before rejecting new calls. This can be useful to prevent a system from being brought down by termi- nating too many simultaneous calls. -m Temporarily mutes output to the console and logs. To return to normal, use logger mute. -M value Limits the maximum number of calls to the specified value. This can be useful to prevent a system from being brought down by termi- nating too many simultaneous calls. -n Disable ANSI colors even on terminals capable of displaying them. -p If supported by the operating system (and executing as root), attempt to run with realtime priority for increased performance and responsiveness within the Asterisk process, at the expense of other programs running on the same machine. Note: astcanary will run concurrently with asterisk. If astcanary stops running or is killed, asterisk will slow down to normal process priority, to avoid locking up the machine. -q Reduce default console output when running in conjunction with console mode (-c). -r Instead of running a new Asterisk process, attempt to connect to a running Asterisk process and provide a console interface for con- trolling it. -R Much like -r. Instead of running a new Asterisk process, attempt to connect to a running Asterisk process and provide a console in- terface for controlling it. Additionally, if connection to the Asterisk process is lost, attempt to reconnect for as long as 30 sec- onds. -s socket file name In combination with -r, connect directly to a specified Asterisk server socket. -t When recording files, write them first into a temporary holding directory, then move them into the final location when done. -T Add timestamp to all non-command related output going to the console when running with verbose and/or logging to the console. -U user Run as user user instead of the calling user. NOTE: this requires substantial work to be sure that Asterisk's environment has per- mission to write the files required for its operation, including logs, its comm socket, the asterisk database, etc. -v Increase the level of verboseness on the console. The more times -v is specified, the more verbose the output is. Specifying this option implies -f and will cause asterisk to no longer fork or detach from the controlling terminal. This option may also be used in conjunction with -r and -R. Note: This always sets the verbose level in the asterisk process, even if it is running in the background. This will affect the size of your log files. -V Display version information and exit immediately. -W Display colored terminal text as if the background were white or otherwise light in color. Normally, terminal text is displayed as if the background were black or otherwise dark in color. -x command Connect to a running Asterisk process and execute a command on a command line, passing any output through to standard out and then terminating when the command execution completes. Implies -r when -R is not explicitly supplied. -X Enables executing of includes via #exec directive. This can be useful if You want to do #exec inside asterisk.conf EXAMPLES
asterisk - Begin Asterisk as a daemon asterisk -vvvgc - Run on controlling terminal asterisk -rx "core show channels" - Display channels on running server BUGS
Bug reports and feature requests may be filed at https://issues.asterisk.org SEE ALSO
http://www.asterisk.org - The Asterisk Home Page http://www.asteriskdocs.org - The Asterisk Documentation Project http://wiki.asterisk.org - The Asterisk Wiki http://www.digium.com/ - Asterisk is sponsored by Digium AUTHOR
Mark Spencer <markster@digium.com> Countless other contributors, see CREDITS with distribution for more information. asterisk 1.8 2011-02-08 asterisk (8)
All times are GMT -4. The time now is 08:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy