Sponsored Content
Top Forums Shell Programming and Scripting awk script throws invalid char expression Post 302799591 by Sudhakar333 on Friday 26th of April 2013 05:47:48 PM
Old 04-26-2013
The input file contains the data as follows:

Code:
<sn:data1="446776766">
<attributes>

     <sn:accessData>MAIL<\sn:accessData>
     ..........
     ...........
     ...........
     <sn:List_sn:Service>
       <sn:Service>4444-555<sn:Service>
       <sn:Service>4444-323<sn:Service>
    <\sn:List_sn:Service>
    .......................
    .....................
    .....................

<\attributes>

<\sn:data1>
<sn:data1="446776768">
<attributes>

     <sn:accessData>MAIL1<\sn:accessData>
     ..........
     ...........
     ...........
     <sn:List_sn:Service>
       <sn:Service>4443-555<sn:Service>
       <sn:Service>4443-323<sn:Service>
    <\sn:List_sn:Service>
    .......................
    .....................
    .....................

<\attributes>
<\sn:data1>

<sn:data1="446776796">
<attributes>

     <sn:accessData>MAIL2<\sn:accessData>
     ..........
     ...........
     ...........
     <sn:List_sn:Service>
       <sn:Service>4232-555<sn:Service>
       <sn:Service>3434-323<sn:Service>
    <\sn:List_sn:Service>
    .......................
    .....................
    .....................
<\attributes>
<\sn:data1>
.........
.........
    
.............
............
...........
...........
..............
.
............
...........
.

..............
.
<sn:data1="336776454">
<attributes>

     <sn:accessData>MAIL3<\sn:accessData>
     ..........
     ...........
     ...........
     <sn:List_sn:Service>
       <sn:Service>4232-8989<sn:Service>
       <sn:Service>3434-354646<sn:Service>
    <\sn:List_sn:Service>
    .......................
    .....................
    .....................
<\attributes>
<\sn:data1>

The script has to read this input file and display the data from the following elements : data1, accessData & Service in an output file in the following format.


Code:
446776766 MAIL  4444-555 4444-555
446776768 MAIL1 4443-555 4443-323
.........
.........

336776454 NORES 4232-8989 4232-8989

The input file is a huge file and using normal script takes lot of time to read the data. Just thought using awk help achieve to read the input data in less time.

Last edited by Scrutinizer; 04-27-2013 at 07:51 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk "Invalid char ' in expession" error

I have an HP PPM (ITG) application that is running an awk command in cygwin bash shell as part of ITG process moving SAP transports on a Windows 2003 server. The awk command checks the first two characters of a file containing return code that was retrieved from the SAP server. It is throwing the... (3 Replies)
Discussion started by: accsam1
3 Replies

2. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

3. Shell Programming and Scripting

sed: -e expression #1, char 21: unterminated `s' command

I have read many threads, but I still didn't find the right answer. May be i didn't find the right thread, though are so many threads for the same question. Basically the situation is - find date in a file and replace it with another date. (its not homework, its part of lot of a big processing,... (10 Replies)
Discussion started by: avinthm
10 Replies

4. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

5. Shell Programming and Scripting

Sed: -e expression #1, char 2: extra characters after command

Greetings.. getting the error while execution of the script, correct where i am missing #!/bin/bash DATE=`date +%Y-%m-%d:::%H:%M` HOSTNAME=`hostname` TXT="/log/temp.txt" LOGPATH="/log1/commanlogs/" IP=`/sbin/ifconfig | grep -i inet| head -n1| awk '{print $2}'| awk -F : '{print $2}'`... (7 Replies)
Discussion started by: manju98458
7 Replies

6. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

7. Programming

Invalid conversion from char* to char

Pointers are seeming to get the best of me and I get that error in my program. Here is the code #include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n" #define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies

8. Shell Programming and Scripting

awk throws makes too many open files

Hi, I have a below awk script. BEGIN { FS=","; } { system("curl -v -H \"Authorization: SSWS test" -H \"Accept: application/json\" -H \"Content-Type: application/json\" -X POST \"https://tes.test.com/api/v1/users?activate=false\" -d \'{ \"profile\": { \"firstName\": \"" $1 "... (7 Replies)
Discussion started by: Krrishv
7 Replies

9. Shell Programming and Scripting

Sed: -e expression #1, char 16: unterminated address regex

I am trying to grep for a particular text (Do action on cell BL330) in a text file(sample.gz) which is searched in the content filtered by date+timestamp (2016-09-14 01:09:56,796 to 2016-09-15 04:10:29,719) on a remote machine and finally write the output into a output file on a local machine. ... (23 Replies)
Discussion started by: rbadveti
23 Replies

10. UNIX for Beginners Questions & Answers

Sed: -e expression #1, char 20: unterminated address regex

I am trying to add word in last of particular line. the same command syntex is running on prompt. but in bash script give error."sed: -e expression #1, char 20: unterminated address regex" Please help. for i in `cat servername`; do ssh -q -t root@$i sed -i '/simple_allow_groups =/s/$/,... (4 Replies)
Discussion started by: yash_message
4 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy