Sponsored Content
Full Discussion: Printing Fixed Width Columns
Top Forums Shell Programming and Scripting Printing Fixed Width Columns Post 302407404 by cixelsyd on Thursday 25th of March 2010 10:38:54 AM
Old 03-25-2010
Alister,

Thank you so much for your help! That did exactly the trick. I modified the script to the following:

Code:
echo -e "From: \t"$frm_Zone"\tTo:\t"$to_Zone
                        
printf '%-5s %-20s %-20s %-20s %-15s %-10s\n' $pol_Id $src_Address $dst_Address "$pol_Service" "$pol_Action" "$pol_Name"

#finding the array with the largest index
#so we now how many times to run the for loop

lnAddy=`echo ${#srcAddyArray[*]}`
lnSrc=`echo ${#dstAddyArray[*]}`
lnSvc=`echo ${#serviceArray[*]}`

max2 $lnAddy $lnSrc
temp=$?
max2 $temp $lnSvc
longest=$?

for (( i = 0; i < longest; i++ )) do

              printf '%-5s %-20s %-20s %-20s\n' "" "${srcAddyArray[$i]}" "${dstAddyArray[$i]}" "${serviceArray[$i]}"

done

I ended up having to print one blank column so it lined up properly, but now the output is exactly how I wanted:
Code:
From:   Trust-cs        To:     Untrust-Firn
615   Any                  mail.acast.xxxx.xxx  tcp-6777 (wo 85073)  Permit Nat SRC  wo 85073  
      69.xx.xxx.1          mail.xxxxxxx.edu     tcp-6788 (wo 85073) 
      75.xxx.44.1          my.xxxxxx.edu        tcp-8008 (wo 85073) 

From:   Trust-cs        To:     DMZ-acad
596   Any                  69.xx.xxx.31         TCP-15888            Permit                    
      tables.noc.xxxx.xxx  mages.icecrown.com   tcp-16888           
                                                TCP-17888           
                                                UDP-17888           
                                                UDP-18888

Thank you so much for your help!
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Help with Fixed width File Parsing

I am trying to parse a Fixed width file with data as below. I am trying to assign column values from each record to variables. When I parse the data, the spaces in all coumns are dropped. I would like to retain the spaces as part of the dat stored in the variables. Any help is appreciated. I... (4 Replies)
Discussion started by: sate911
4 Replies

2. Shell Programming and Scripting

Combining Two fixed width columns to a variable length file

Hi, I have two files. File1: File1 contains two fixed width columns ID of 15 characters length and Name is of 100 characters length. ID Name 1-43<<11 spaces>>Swapna<<94 spaces>> 1-234<<10 spaces>>Mani<<96 spaces>> 1-3456<<9 spaces>>Kapil<<95 spaces>> File2: ... (4 Replies)
Discussion started by: manneni prakash
4 Replies

3. Shell Programming and Scripting

Fixed-Width file from Oracle

Hi All, I have created a script which generates FIXED-WIDTH file by executing Oracle query. SELECT RPAD(NVL(col1,CHR(9)),20)||NVL(col2,CHR(9))||NVL(col3,CHR(9) FROM XYZ It generates the data file with proper alignment. But if same file i transfer to windows server or Mainframe... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies

4. Shell Programming and Scripting

Comparing two fixed width file

Hi Guys I am checking the treads to get the answer but i am not able to get the answer for my question. I have two files. First file is a pattern file and the second file is the file i want to search in it. Output will be the lines from file2. File1: P2797f12af 44751228... (10 Replies)
Discussion started by: anshul_er
10 Replies

5. Shell Programming and Scripting

variable fixed-width fields

Hi there, CTL Port IO Rate(IOPS) Read Rate(IOPS) Write Rate(IOPS) Read Hit(%) Write Hit(%) Trans. Rate(MB/S) Read Trans. Rate(MB/S) Write Trans. Rate(MB/S) 09:36:48 0 A 136 0 135 97 100 ... (6 Replies)
Discussion started by: gray380
6 Replies

6. Shell Programming and Scripting

How to parse fixed-width columns which may include empty fields?

I am trying to selectively display several columns from a db2 query, which gives me a fixed-width output (partial output listed here): --------- -------------------------- ------------ ------ 000 0000000000198012 702 29 000 0000000000198013 ... (9 Replies)
Discussion started by: ahsh79
9 Replies

7. Shell Programming and Scripting

Removing duplicates in fixed width file which has multiple key columns

Hi All , I have a requirement where I need to remove duplicates from a fixed width file which has multiple key columns .Also , need to capture the duplicate records into another file . File has 8 columns. Key columns are col1 and col2. Col1 has the length of 8 col 2 has the length of 3. ... (5 Replies)
Discussion started by: saj
5 Replies

8. UNIX for Dummies Questions & Answers

Length of a fixed width file

I have a fixed width file of length 53. when is try to get the lengh of the record of that file i get 2 different answers. awk '{print length;exit}' <File_name> The above code gives me length 50. wc -L <File_name> The above code gives me length 53. Please clarify on... (2 Replies)
Discussion started by: Amrutha24
2 Replies

9. Shell Programming and Scripting

Alter Fixed Width File

Thank u so much .Its working fine as expected. ---------- Post updated at 03:41 PM ---------- Previous update was at 01:46 PM ---------- I need one more help. I have another file(fixed length) that will get negative value (ex:-00000000003000) in postion (98 - 112) then i have to... (6 Replies)
Discussion started by: vinus
6 Replies

10. Shell Programming and Scripting

Joining fixed width files

Hi All, I need to join fixed width files on a column which is position 1 to 3 and need to have all the records from file1 file1.txt Cu1nullL1L2 Cu2nullL1L2 Cu3nullL1L2 file2.txt Cu1B1B2 Cu3B1B2 output.txt Cu1L1B1L2B2 Cu2L1L2 Cu3L1B1L2B3 I tried but not getting the expected... (12 Replies)
Discussion started by: shash
12 Replies
tapset::tcp(3stap)														tapset::tcp(3stap)

NAME
tapset::tcp - systemtap tcp tapset DESCRIPTION
This family of probe points is used to probe events that occur in the TCP layer, tcp.sendmsg Sending a tcp message See probe::tcp.sendmsg(3stap) for details. tcp.sendmsg.return Sending TCP message is done See probe::tcp.sendmsg.return(3stap) for details. tcp.recvmsg Receiving TCP message See probe::tcp.recvmsg(3stap) for details. tcp.recvmsg.return Receiving TCP message complete See probe::tcp.recvmsg.return(3stap) for details. tcp.disconnect TCP socket disconnection See probe::tcp.disconnect(3stap) for details. tcp.disconnect.return TCP socket disconnection complete See probe::tcp.disconnect.return(3stap) for details. tcp.setsockopt Call to setsockopt() See probe::tcp.setsockopt(3stap) for details. tcp.setsockopt.return Return from setsockopt() See probe::tcp.setsockopt.return(3stap) for details. tcp.receive Called when a TCP packet is received See probe::tcp.receive(3stap) for details. SEE ALSO
probe::tcp.sendmsg(3stap), probe::tcp.sendmsg.return(3stap), probe::tcp.recvmsg(3stap), probe::tcp.recvmsg.return(3stap), probe::tcp.disconnect(3stap), probe::tcp.disconnect.return(3stap), probe::tcp.setsockopt(3stap), probe::tcp.setsockopt.return(3stap), probe::tcp.receive(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::tcp(3stap)
All times are GMT -4. The time now is 11:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy