formating output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting formating output
# 15  
Old 02-01-2007
Can you please explain me this FS and RS please
# 16  
Old 02-01-2007
yeah thats right..Itz giving me wrong process id's

crypto $ awk '/idle/{sub(/s.*/,"",$2);sub(/<\/td>.*/,"",$3); proc=$3;if(($3~/^&/)||(($2+0)>20000))print "Idle is:",$2, "Process is:"
, proc , "PID is:", $4}' \FS="idle |s</td><td>|/logs/imanscript" RS=".syslog" proc.txt
Idle is: 4639 Process is: &nbsp; PID is: 3568
Idle is: 20419 Process is: X045672&nbsp; PID is: 16225
Idle is: 25666 Process is: X035466&nbsp; PID is: 561
Idle is: 30690 Process is: 103818&nbsp; PID is: 16278
Idle is: 24137 Process is: X039371&nbsp; PID is: 15120
Idle is: 32917 Process is: 22320&nbsp; PID is: 25488

actually 3568 is a owned process.. here is the column for your reference.

</pre>
<hr>
<H2>Processes</H2><table align=center width=100% border=1><tr><th>No.</th><th>State</th><th>Query</th><th>Times</th><th>User</th><th
>Processed</th><th>Syslog</th></tr><tr><td>1</td><td>ready</td><td>&nbsp;</td><td>idle 4639s</td><td>&nbsp;</td><td>0</td><td>/Appli
cation/ugsvols/bldata01/logs/imanscript3568.syslog</td></tr><tr><td>2</td><td>ready</td><td>&nbsp;</td><td>idle 4628s</td><td>X04018
7&nbsp;</td><td>3</td><td>/Application/ugsvols/bldata01/logs/imanscript896.syslog</td></tr><tr><td>3</td><td>ready</td><td>&nbsp;</t
d><td>idle 4276s</td><td>X041587&nbsp;</td><td>33</td><td>/Application/ugsvols/bldata01/logs/imanscript29204.syslog</td></tr><tr><td
>4</td><td>ready</td><td>&nbsp;</td><td>idle 10535s</td><td>106641&nbsp;</td><td>7</td><td>/Application/ugsvols/bldata01/logs/imansc
ript9994.syslog</td></tr><tr><td>5</td><td>ready</td><td>&nbsp;</td><td>idle 8982s</td><td>X039706&nbsp;</td><td>194</td><td>/Applic
ation/ugsvols/bldata01/logs/imanscript7599.syslog</td></tr><tr><td>6</td><td>ready</td><td>&nbsp;</td><td>idle 13046s</td><td>X03609
1&nbsp;</td><td>24</td><td>/Application/ugsvols/bldata01/logs/imanscript1963.syslog</td></tr><tr><td>7</td><td>ready</td><td>&nbsp;<
/td><td>idle 20419s</td><td>X045672&nbsp;</td><td>7</td><td>/Application/ugsvols/bldata01/logs/imanscript16225.syslog</td></tr><tr><
td>8</td><td>ready</td><td>&nbsp;</td><td>idle 630s</td><td>X035077&nbsp;</td><td>9</td><td>/Application/ugsvols/bldata01/logs/imans
cript10210.syslog</td></tr><tr><td>9</td><td>ready</td><td>&nbsp;</td><td>idle 25666s</td><td>X035466&nbsp;</td><td>5</td><td>/Appli
cation/ugsvols/bldata01/logs/imanscript561.syslog</td></tr><tr><td>10</td><td>ready</td><td>&nbsp;</td><td>idle 30690s</td><td>10381
8&nbsp;</td><td>5</td><td>/Application/ugsvols/bldata01/logs/imanscript16278.syslog</td></tr><tr><td>11</td><td>ready</td><td>&nbsp;
</td><td>idle 24137s</td><td>X039371&nbsp;</td><td>15</td><td>/Application/ugsvols/bldata01/logs/imanscript15120.syslog</td></tr><tr
><td>12</td><td>ready</td><td>&nbsp;</td><td>idle 32917s</td><td>22320&nbsp;</td><td>4</td><td>/Application/ugsvols/bldata01/logs/im
anscript25488.syslog</td></tr></table>
<hr>
<H2>Queries</H2><p>No queries.</p>
# 17  
Old 02-01-2007
Quote:
Originally Posted by Krrishv
Can you please explain me this FS and RS please
FS is input field separator, RS is input record separator.
Read the man pages for awk.
# 18  
Old 02-01-2007
Thank You Buddy. It works great.

Last edited by Krrishv; 02-01-2007 at 09:46 AM..
# 19  
Old 02-02-2007
radoulov

One final question. Could you please explain me this.I really couldn't understand much.

awk '/idle/{sub(/s.*/,"",$2);sub(/<\/td>.*/,"",$3); proc=$3;if(($3~/^&/)||(($2+0)>20000))

Thanks.
# 20  
Old 02-02-2007
Quote:
Originally Posted by Krrishv
One final question. Could you please explain me this.I really couldn't understand much.

awk '/idle/{sub(/s.*/,"",$2);sub(/<\/td>.*/,"",$3); proc=$3;if(($3~/^&/)||(($2+0)>20000))
I'll try (feel free to correct my english) ...

Code:
awk '
# For every record matching the pattern "idle":
# + in the second field ($2) remove (replace with "") everything
# + after and including the regex "s.*" (letter "s" followed by 
# + any number of any character), in the 3rd field ($3), 
# + remove (replace with "") everything after and including 
# + the regex "<\/td>.*" (</td>, forward slash needs to be escaped,
# + followed by any number of any character); then assign the _modified_
# + value of $3 to the variable proc.
# If the value of the variable proc matches the regex "^&" (& character 
# + at the beginig) _OR_ the value of the second filed (for some awk
# + implementations you need some sort of explicit casting/conversion,  
# + in this case to number with a "fake" addition ($2+0)) is greater than
# + 20000, perform some actions ....
/idle/{sub(/s.*/,"",$2);sub(/<\/td>.*/,"",$3); proc=$3;if(($3~/^&/)||(($2+0)>20000))
....

# 21  
Old 02-02-2007
Thanks rudolv.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies

2. UNIX for Dummies Questions & Answers

Help with formating when using mailx

Hi I am a newbie here. I tried searching for the solution but I guess I either didn't find it or there hasn't been one posted. my problem is I spooled the results of a query into a .txt file. When I cat the file the formating looks great. All the columns are aligned. However once I mailx the... (2 Replies)
Discussion started by: RB26DETT
2 Replies

3. UNIX for Advanced & Expert Users

remove print formating from printer output file

I have a print file taken from the print spooler and I want to delete all the formatting leaving only the text. If you vi the file it shows "\304\304 ...." which translates into a printed line on print output. I need to be able to edit and pass this file to another process Thnaks (10 Replies)
Discussion started by: petercp
10 Replies

4. UNIX for Advanced & Expert Users

Formating and Parsing Autosys output

if you want to parse the output from an autosys you can use the below autorep -j Prefix_% | awk '{ if ($6 ~ /^/) printf "%-20s \t\t %-20s\n",$1,$5 ; else if ($6 ~ /^/) printf "%-20s \t\t %-20s\n",$1,$6; else printf "%-20s \t\t %-20s\n",$1,$4 }' | awk '{ if ($2... (1 Reply)
Discussion started by: phpsnook
1 Replies

5. Shell Programming and Scripting

Formating output

Hello Team i have a file with following data (as columns). I need implement a syntax like below for altering table ALTER TABLE1 TABLENAME ADD COLUMN COL1 CHAR(5) NOT NULL WITH DEFAULT ADD COLUMN COL2 CHAR(5) .. .. ADD COLUMN COLn CHAR(5) NOT NULL... (1 Reply)
Discussion started by: rocking77
1 Replies

6. Shell Programming and Scripting

formating output

Hi all, I want to start a new topic on this matter I have this script, #!perl use strict; use warnings; use Data::Dumper; open my $log, '>', 'log-external.txt' or die "Could not open log: $!"; print $log "Subnet,Static,DHCP,Unused\n"; open my $dump, '>', 'dump.log' or die... (2 Replies)
Discussion started by: richsark
2 Replies

7. Shell Programming and Scripting

Problem In Formating Table as Output

Hi! I'm working a program that collects 4 various inputs and format my output into tabular form.Problem is my table margins move with different character lengths. Is there a way to fix my table margins even though the variables inside the table varies in length? thank you very much...:( (1 Reply)
Discussion started by: Lo11001
1 Replies

8. Shell Programming and Scripting

Output formating

Dear All I am stuck in one problem. Kindly help me. I am taking below mention file as input file and want some op file as mention below. Kindly send me all possible suggestion and query. Thnaks Jaydeep bELOW IS THE INPUT FILE: *** Connected to BSCANGR ***... (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

9. Shell Programming and Scripting

formating array file output using perl

Hello, I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example: @array= 1..14; Needs to be output to the file like so: 1 ... (4 Replies)
Discussion started by: seismic_willy
4 Replies

10. Shell Programming and Scripting

Formating cal output

Hi Gurus, In my Cal output i want to cut the date of 2nd saturday how tyo achive this. for eg in the below output i need that second saturday 13 to be cut. crypto $ cal January 2007 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26... (2 Replies)
Discussion started by: Krrishv
2 Replies
Login or Register to Ask a Question