Sponsored Content
Full Discussion: AWK\SED advice
Top Forums Shell Programming and Scripting AWK\SED advice Post 302256402 by Annihilannic on Sunday 9th of November 2008 08:13:32 PM
Old 11-09-2008
Not sure I understand your requirement exactly (I'm presuming "test1" is a "user" of that code from the context), but this should produce a conveniently searchable list mapping users to countries:

Code:
awk '
        /^</ { user=$1; sub("<","",user) }
        /EVENT_COUNTRIES/ { for (i=3; i<=NF; i++) print user,$i }
' inputfile > outputfile

For this test data:

Code:
<test1
        CONNECT_TYPE = COPY
        HOST =
        USER =
        PASSWORD =

        EVENT_FORMATS = EVENT 854
        EVENT_COUNTRIES = 101 102 103 6 99

        DEST = /usr/local/production/event/

        LOG_DIR = /usr/local/production/event/log
>
<test2
        CONNECT_TYPE = COPY
        HOST =
        USER =
        PASSWORD =

        EVENT_FORMATS = EVENT 854
        EVENT_COUNTRIES = 104 28 3 6 99

        DEST = /usr/local/production/event/

        LOG_DIR = /usr/local/production/event/log
>

The results are:

Code:
test1 101
test1 102
test1 103
test1 6
test1 99
test2 104
test2 28
test2 3
test2 6
test2 99

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need advice: Awk vs something else?

I have a while read loop cycling through a fixed-length csv file and I'd like to use an if statement to check two fields in each line. I'm basically asking for your suggestions on the best and easiest way to check two fields in each line. I'm sure many of you may be thinking just use awk, but if... (1 Reply)
Discussion started by: yongho
1 Replies

2. UNIX for Advanced & Expert Users

sed in awk ? or nested awk ?

Hey all, Can I put sed command inside the awk action ?? If not then can i do grep in the awk action ?? For ex: awk '$1=="174" { ppid=($2) ; sed -n '/$ppid/p' tempfind.txt ; }' tempfind.txt Assume: 174 is string. Assume: tempfind.txt is used for awk and sed both. tempfind.txt... (11 Replies)
Discussion started by: varungupta
11 Replies

3. Shell Programming and Scripting

need advice on AWK

Hallo Guys, I have an sql script which gives me the output below: LOGIN_ID ACTION_CODE DATE CASE_REFERENCE FRAUD_TYPE_ID ESTIMATE_LOSS james_j Assign 17/03/2008 0833003470 High Frequency 77513.92 james_j Assign 17/03/2008 0838117486 High Aggregate Cost of Calls 149830.5... (14 Replies)
Discussion started by: kekanap
14 Replies

4. UNIX for Dummies Questions & Answers

Sed and Awk Help

I am trying to grab some text from an HTML file. I have something similar to this: <tr> <td><a href="somepath.html">Some Text<HR></HR></a></td> </tr> <tr> <td><a href="somepath.html" >Some More Text<HR></HR></a></td> </tr> And just want the bolded text. Any suggestions? (15 Replies)
Discussion started by: ryanewing
15 Replies

5. Shell Programming and Scripting

Some more help with Awk/Sed

hi I have a file called trom.txt whose contents are: Malaria|\\nAIX\abcd\newone\files\Malarias.dat|1|20090224|0|Taxi Complete|2009-02-23 04:26:00 Product|\\nAIX\abcd\newone\files\slint.dat|1|20090224|0|Taxi Complete|2009-02-23 04:26:00... (2 Replies)
Discussion started by: zainravi
2 Replies

6. Shell Programming and Scripting

What to use : awk or sed

Hi All, I am a bit confused,Can anyone help; My problem is that i have a flat file in this format 8.10 USAccountSummaryClone1 3.10 USAccountSummaryClone2 2.80 GlobalUserManagementClone1 2.10 BasicServicesClone2 1.60 MYCAServicesClone2 1.30 INTLEStatementClone1 0.90... (6 Replies)
Discussion started by: usha rao
6 Replies

7. Shell Programming and Scripting

awk and sed

awk and sed anyone? sample: server2 /sbin/powermt display|grep -E "failed|degraded" > server3 /sbin/powermt display|grep -E "failed|degraded" > output: server2 'hostname;/sbin/powermt display|grep -E "failed|degraded"' > server3 'hostname;/sbin/powermt display|grep -E... (2 Replies)
Discussion started by: invinzin21
2 Replies

8. Shell Programming and Scripting

Advice on using awk in ksh with system date

OK I have a simple awk script: $ awk '/03\/11\/10/' foofile|awk -f finderrors.awk I want to use in the ksh script to so that I can do something like this: #!/bin/ksh TODAY=`date +"%D"` awk /$TODAY/ foofile|awk -f finderrors.awk The problem I am having is (I believe) is with the special... (3 Replies)
Discussion started by: bike4life
3 Replies

9. UNIX for Dummies Questions & Answers

How to do this using awk/sed

Hi , i have records like select '##col1:'||col1||'##col2:' from ( select col1 , col2 Rank () rank_na over ( PARTITION BY col1 , col2 ORDER BY col1 DESC ) from table1 where rank_na > 1 i want to extract col1 and col2 in 1 variable and table1 in script variable Thanks in Advance... (3 Replies)
Discussion started by: max_hammer
3 Replies

10. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies
CSREQ(1)						    BSD General Commands Manual 						  CSREQ(1)

NAME
csreq -- Expert tool for manipulating Code Signing Requirement data SYNOPSIS
csreq [-v] -r requirement-input -t csreq [-v] -r requirement-input -b outputfile DESCRIPTION
The csreq command manipulates Code Signing Requirement data. It reads one requirement from a file or command arguments, converts it into internal form, checks it, and then optionally outputs it in a different form. The options are as follows: -b path Requests that the requirement read be written in binary form to the path given. -r requirement-input Specifies the input requirement. See "specifying requirements" below. This is exactly the same format as is accepted by the -r and -R options of the codesign(1) command. -t Requests that the requirement read be written as text to standard output. -v Increases the verbosity of output. Multiple instances of -v produce increasing levels of commentary output. In the first synopsis form, csreq reads a Code Requirement and writes it to standard output as canonical source text. Note that with text input, this actually compiles the requirement into internal form and then converts it back to text, giving you the system's view of the requirement code. In the second synopsis form, csreq reads a Code Requirement and writes its binary representation to a file. This is the same form produced by the SecRequirementCopyData API, and is readily acceptable as input to Code Signing verification APIs. It can also be used as input to subse- quent invocations of csreq by passing the filename to the -r option. SPECIFYING REQUIREMENTS
The requirement argument (-r) can be given in various forms. A plain text argument is taken to be a path to a file containing the require- ment. This program will accept both binary files containing properly compiled requirements code, and source files that are automatically com- piled for use. An argument of "-" requests that the requirement(s) are read from standard input. Again, standard input can contain either binary form or text. Finally, an argument that begins with an equal sign "=" is taken as a literal requirements source text, and is compiled accordingly for use. EXAMPLES
To compile an explicit requirement program and write its binary form to file "output": csreq -r="identifier com.foo.test" -b output.csreq To display the requirement program embedded at offset 1234 of file "foo": tail -b 1234 foo | csreq -r- -t FILES
DIAGNOSTICS
The csreq program exits 0 on success or 1 on failure. Errors in arguments yield exit code 2. SEE ALSO
codesign(1) HISTORY
The csreq command first appeared in Mac OS 10.5.0 . BSD
June 1, 2006 BSD
All times are GMT -4. The time now is 11:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy