Formatting output using awk in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting output using awk in ksh
# 1  
Old 07-17-2013
Formatting output using awk in ksh

Smiliei was trying to write a script to format output of a command in ksh which has output as below:
Quote:
jobname mm/dd/yy hh:mm:ss mm/dd/yy hh:mm:ss status run_number exit_code
so i used :

Quote:
command | awk '{ print ""$1" \t\t",$2" ",$3" ",$4" ",$5" ",$6}'
to get

Quote:
jobname mm/dd/yy hh:mm:ss mm/dd/yy hh:mm:ss status
which i require at all times. But problem occurs when status part changes. above output i get when status is SU (success).If the status is IN (inactive), output of command is:
Quote:
jobname ----- mm/dd/yy hh:mm:ss IN run_number exit_code
and if status is RU (running), output of command is

Quote:
jobname mm/dd/yy hh:mm:ss ----- RU run_number exit_code
and if status is AC (activated), output of command is

Quote:
jobname ----- ----- AC run_number exit_code
the awk construct that i use is ok for SU status, i need an awk construct that gives similar output for all status. Something like :

Quote:
jobname ----- ----- AC
or
Quote:
jobname mm/dd/yy hh:mm:ss ----- RU
or
Quote:
jobname ----- mm/dd/yy hh:mm:ss IN
or
Quote:
jobname mm/dd/yy hh:mm:ss mm/dd/yy hh:mm:ss SU
i got my construct to work with th SU status alone, i wanted to have one single awk construct that handles all the status. Can someone help me in the code ?
# 2  
Old 07-17-2013
Can you paste a sample output of the command in ksh. It would help if we can understand the input data that awk should work on, to provide correct solution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in formatting output in sed / awk

I have a file like this : ! 1 ! 542255 ! 50,140.00 ! ! 2 ! 551717 ! 5,805.00 ! ! 3 ! 551763 ! 8,130.00 ! ! 4 ! 551779 ! 750.00 ! ! 5 ! 551810 ! 56,580.00 ! ! 6 ! 551816 ! 1,350.00 ! ! 7 ! 551876 ! 360.00 ! ! 8 ! 551898 ! ... (10 Replies)
Discussion started by: adam1969in
10 Replies

2. Shell Programming and Scripting

awk Script Output in Outlook Formatting Issue

When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Discussion started by: Ariean
1 Replies

3. Shell Programming and Scripting

ksh : need to store the output of a awk command to a array

I have awk command : awk -F ' ' '{ print $NF }' log filename And it gives the output as below: 06:00:00 parameters: SDS (2) no no no no doc=4000000000). information: (6 Replies)
Discussion started by: ramprabhum
6 Replies

4. Shell Programming and Scripting

Formatting grep and awk output

Hi there. I have a very large file and I am trying to format it so that I can pull out certain pieces of data/info and report it in spreadsheet format/style. The file has ###### which will separate each line that will be listed in the spreadsheet. Whenever I find "No" at the end of a line I want... (7 Replies)
Discussion started by: kieranfoley
7 Replies

5. Shell Programming and Scripting

Formatting of output from awk

Hi; i m running an command like; getfacl $(find /home/fstl/testShell/ -type f -ls | awk '{print $11}') and i m getting outpiut for all files in "testShell" folder as; # file: home/fstl/testShell/.script1.sh.swp # owner: root # group: root user:fstl:rw- user:ajay:rw- group:root:r--... (1 Reply)
Discussion started by: ajaypadvi
1 Replies

6. Shell Programming and Scripting

output formatting with awk.

# echo $PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin How would i write a script to display permission on each folders in $PATH variable below format. drwxr-xr-x 2 0 root 4096 Nov 24 14:51 /usr/kerberos/sbin drwxr-xr-x 2 0... (2 Replies)
Discussion started by: pinga123
2 Replies

7. Shell Programming and Scripting

ksh/awk help - output missing numbers

Here is what I am trying to do: I have a list of numbers that I pulled from an awk command in a column like so: 1 3 4 7 8 I want to find which numbers in the list are missing out of a range. So let's say I want to find out from the list above which numbers are missing from the... (6 Replies)
Discussion started by: afavis
6 Replies

8. Shell Programming and Scripting

formatting date in ksh

hi all, in ksh, how do i format date so it includes hour and minute ?? i am trying the following command : date +%Om/%Od/%Oy%OH:%M but it displays the hour and minute concatenated with the day/month/year e.g 12/10/0814:08 when i want the output to be 12/10/08 14:08 i tried... (4 Replies)
Discussion started by: cesarNZ
4 Replies

9. Shell Programming and Scripting

Question about formatting output using AWK

Hi everyone. I've got this fille... 0 5000001 5000002 5000003 5000006 5000007 5000219 11000156 11003130 11003132and this script... #!/bin/ksh FILE_ALERT_CONTACT_LIST=users.txt userID=`awk -F"=" '{printf $1 ", "}' $FILE_ALERT_CONTACT_LIST` (9 Replies)
Discussion started by: Fatbob
9 Replies

10. UNIX for Advanced & Expert Users

formatting textfile inside ksh script using awk not working

I cannot seem to get this text file to format. Its as if the awk statement is being treated as a simple cat command. I manned awk and it was very confusing. I viewed previous posts on this board and I got the same results as with the the awk command statement shown here. Please help. ... (6 Replies)
Discussion started by: tekline
6 Replies
Login or Register to Ask a Question