Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help with awk'ing formatting this Post 302825001 by newbie_01 on Sunday 23rd of June 2013 01:22:10 AM
Old 06-23-2013
Help with awk'ing formatting this

Hi,

I have a file below that I am wanting to awk. The lines of relevance are lines 7 and 9

Code:
$ nl /tmp/x

     1  ADRCI: Release 11.2.0.3.0 - Production on Sun Jun 23 17:01:02 2013

     2  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

     3  ADR base = "/u01/app/grid"
     4  adrci> adrci>
     5  ADR Home = /u01/app/grid/diag/asm/user_grid/host_3970975860_80:
     6  *************************************************************************
     7  ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME             
     8  -------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
     9  1459756123           720                  8760                 2011-05-16 18:00:59.590482 +12:00                                                                                          1                    2                    80                   1                    2011-05-16 18:00:59.590482 +12:00
    10  1 rows fetched

    11  adrci>
$

At the moment what I am doing is re-directing both lines to a file each using sed. Is there any way that I can awk it right away once I re-direct the output to a file?

The line that is important is line 7, I was hoping I can reference each field based on each heading. For example, if want to be able access SHORTP_POLICY and shows 720 :-)

I do not have much control on how the output looks like and I hope it stays this way even on future Oracle upgrades ... grrr ....

FYI, shell that I am using is ksh.

Any feedback much appreciated. Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatting using awk

Let's say I write a simple script that contains the following: date | awk '{print $1}' date | awk '{print $2}' Of course, when I run the script the output will look similar to: Tue Mar What if I want my ouput to be on one line as follows: Tue Mar What changes would I need to... (2 Replies)
Discussion started by: cdunavent
2 Replies

2. Shell Programming and Scripting

grep'ing and sed'ing chunks in bash... need help on speeding up a log parser.

I have a file that is 20 - 80+ MB in size that is a certain type of log file. It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example: The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
Discussion started by: elinenbe
4 Replies

3. Shell Programming and Scripting

pipe'ing grep output to awk

This script is supposed to find out if tomcat is running or not. #!/bin/sh if netstat -a | grep `grep ${1}: /tomcat/bases | awk -F: '{print $3}'` > /dev/null then echo Tomcat for $1 running else echo Tomcat for $1 NOT running fi the /tomcat/bases is a file that... (2 Replies)
Discussion started by: ziggy25
2 Replies

4. Shell Programming and Scripting

String formatting using AWK

Hi, I need to insert a line at a particular line number. I am using the below code: sed $REV_LINO_NO" i\\ # $CURRENT_DATE $NAME Changed pwd for cindy\'s id" file > file1 This code works, but the formatting is not as I expected. For example, I get lines as shown below... (2 Replies)
Discussion started by: sugan
2 Replies

5. Shell Programming and Scripting

AWK formatting help.

Dear all I require help with AWK regarding this situation Input is : fn1 12345 fn1 23456 fn3 231513 fn1 22325 fn3 123125 Desired output is fn1 12345 23456 22325 fn3 231513 123125 (5 Replies)
Discussion started by: Peasant
5 Replies

6. Shell Programming and Scripting

formatting awk

when i try this awk its giving out put as below. awk '!(/^$/||/--/||/selected/||/^ *$/){print $1}' tmp.txt output ===== 1 2010-08-03-12.31.26.126000 how excluede the 1st line ? i mean i want output only 2nd line i.e 2010-08-03-12.31.26.126000; (5 Replies)
Discussion started by: rocking77
5 Replies

7. Shell Programming and Scripting

Formatting a report using awk

Our vendor produces a report that I would like to format in a particular way. Here is the sample output from their report: # AA.INDEX 2 11 2 239 52 (7,2) 07 MAY 11 203.1 55 # ACCOUNT 2 89561 2 ... (4 Replies)
Discussion started by: thaller
4 Replies

8. UNIX for Dummies Questions & Answers

awk formatting

Hi all, I'm writing a simple awk code: awk 'BEGIN {FS="|"};{print "Type\tNumber\ttypes\tTotal";};{print $1, "\t", $2, "\t", $3, "\t", $4, "\t";}' db_query.txt it gives me the result: Type Number types Total XXX 498.0 5100.0 5274.661 Type Number types Total... (7 Replies)
Discussion started by: messi777
7 Replies

9. Shell Programming and Scripting

awk : finding and formatting

Hi , I was trying to find files of a particular date and did that but then I also wanted to format a field based on some condition so had put another if else in awk. Now it is getting the files of particular date or also the files which are matching that if else condition. find . -name "*"... (1 Reply)
Discussion started by: abhi1988sri
1 Replies

10. Shell Programming and Scripting

Data formatting using awk

Need assistance on the data extraction using awk Below is the format and would like to extract the data in another format ------------------------------------------------------------------------------------------------- Minimum Temperature (deg F ) DAY 1 2 3 4 5 6 7 8 9 10 11... (4 Replies)
Discussion started by: ajayram_arya
4 Replies
is  a  text formatter.	Its input consists of the text to be out-
put, intermixed with formatting commands.  A  formatting  command
is  a  line  containing  the  control character followed by a two
character command name, and possibly one or more arguments.   The
control  character is initially . (dot).  The formatted output is
produced on standard output.  The formatting commands are  listed
below, with being a number, being a character, and being a title.
A + before n means it may be signed,  indicating  a  positive  or
negative change from the current value.  Initial values for where
relevant, are given in parentheses.
  .ad	  Adjust right margin.
  .ar	  Arabic page numbers.
  .br	  Line break.  Subsequent text will begin on a new line.
  .bl n   Insert n blank lines.
  .bp +n  Begin new page and number it n. No n means +1.
  .cc c   Control character is set to c.
  .ce n   Center the next n input lines.
  .de zz  Define a macro called zz. A line with .. ends definition.
  .ds	  Double space the output. Same as .ls 2.
  .ef t   Even page footer title is set to t.
  .eh t   Even page header title is set to t.
  .fi	  Begin filling output lines as full as possible.
  .fo t   Footer titles (even and odd) are set to t.
  .hc c   The character c (e.g., %) tells roff where hyphens are permitted.
  .he t   Header titles (even and odd) are set to t.
  .hx	  Header titles are suppressed.
  .hy n   Hyphenation is done if n is 1, suppressed if it is 0. Default is 1.
  .ig	  Ignore input lines until a line beginning with .. is found.
  .in n   Indent n spaces from the left margin; force line break.
  .ix n   Same as .in but continue filling output on current line.
  .li n   Literal text on next n lines.  Copy to output unmodified.
  .ll +n  Line length (including indent) is set to n (65).
  .ls +n  Line spacing: n (1) is 1 for single spacing, 2 for double, etc.
  .m1 n   Insert n (2) blank lines between top of page and header.
  .m2 n   Insert n (2) blank lines between header and start of text.
  .m3 n   Insert n (1) blank lines between end of text and footer.
  .m4 n   Insert n (3) blank lines between footer and end of page.
  .na	  No adjustment of the right margin.
  .ne n   Need n lines.  If fewer are left, go to next page.
  .nn +n  The next n output lines are not numbered.
  .n1	  Number output lines in left margin starting at 1.
  .n2 n   Number output lines starting at n.  If 0, stop numbering.
  .ni +n  Indent line numbers by n (0) spaces.
  .nf	  No more filling of lines.
  .nx f   Switch input to file f.
  .of t   Odd page footer title is set to t.
  .oh t   Odd page header title is set to t.
  .pa +n  Page adjust by n (1).  Same as .bp
  .pl +n  Paper length is n (66) lines.
  .po +n  Page offset.	Each line is started with n (0) spaces.
  .ro	  Page numbers are printed in Roman numerals.
  .sk n   Skip n pages (i.e., make them blank), starting with next one.
  .sp n   Insert n blank lines, except at top of page.
  .ss	  Single spacing.  Equivalent to .ls 1.
  .ta	  Set tab stops, e.g., .ta 9 17 25 33 41 49 57 65 73 (default).
  .tc c   Tabs are expanded into c.  Default is space.
  .ti n   Indent next line n spaces; then go back to previous indent.
  .tr ab  Translate a into b on output.
  .ul n   Underline the letters and numbers in the next n lines.
All times are GMT -4. The time now is 12:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy