Sponsored Content
Top Forums Shell Programming and Scripting How can I format a text file into uniform columns? Post 302633037 by bigbuk on Tuesday 1st of May 2012 08:48:09 AM
Old 05-01-2012
Thanks for all the replies guys. The closest I get to work on the actual (real) file I am using is ygemici's suggestion.

The actual file I am using looks like :
Code:
CCEBP2Cluster-MQ-Listener-PNGWSC46 State            s2wsc4     ONLINE
CCEBP2Cluster-MQ-Listener-PNGWSC56 State            s2wsc4     ONLINE
CCEBP2Cluster-MQ-QMGR-PNGWSC46 State                    s2wsc4     ONLINE
CCEBP2Cluster-MQ-QMGR-PNGWSC56 State                    s2wsc4     ONLINE
CCEBP2Cluster-WAS-cebgr1-jvm-61n-prodc-c-1 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-cebgr1-jvm-61n-prodc-c-2 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-cebss-jvm-61n-prodc-c-1 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-cebss-jvm-61n-prodc-c-2 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-ew-jvm-61n-prodc-c-1 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-ew-jvm-61n-prodc-c-2 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-node-61n-prodc-c-1 State                s2wsc4     ONLINE
CCEBP2Cluster-WAS-node-61n-prodc-c-3 State                s2wsc4     ONLINE
CCEBP2ClusterApp-z-wpcp22-Patrolagent State            s2wsc4     ONLINE
CCEBP2ClusterDiskGroup State               s2wsc4     ONLINE
CCEBP2ClusterIPAddressProxy State            s2wsc4     ONLINE
CCEBP2ClusterMount-z-wpcp22-01 State              s2wsc4     ONLINE
CCEBP2ClusterZone-z-wpcp22 State               s2wsc4     ONLINE

After running :
Code:
awk -F"," '{ printf "%-10s %-10s %-10s %-10s %-10s %-10s\n", $1, $2 , $3 ,$4, $5, $6 }' filename

I get this file concatenated together :
Code:
CCEBP2Cluster-MQ-Listener-PNGWSC46States2wsc4
CCEBP2Cluster-MQ-Listener-PNGWSC56States2wsc4
CCEBP2Cluster-MQ-QMGR-PNGWSC46States2wsc4
CCEBP2Cluster-MQ-QMGR-PNGWSC56States2wsc4
CCEBP2Cluster-WAS-cebgr1-jvm-61n-prodc-c-1States2wsc4
CCEBP2Cluster-WAS-cebgr1-jvm-61n-prodc-c-2States2wsc4
CCEBP2Cluster-WAS-cebss-jvm-61n-prodc-c-1States2wsc4
CCEBP2Cluster-WAS-cebss-jvm-61n-prodc-c-2States2wsc4
CCEBP2Cluster-WAS-ew-jvm-61n-prodc-c-1States2wsc4
CCEBP2Cluster-WAS-ew-jvm-61n-prodc-c-2States2wsc4
CCEBP2Cluster-WAS-node-61n-prodc-c-1States2wsc4
CCEBP2Cluster-WAS-node-61n-prodc-c-3States2wsc4
CCEBP2ClusterApp-z-wpcp22-PatrolagentStates2wsc4
CCEBP2ClusterDiskGroupStates2wsc4
CCEBP2ClusterIPAddressProxyStates2wsc4
CCEBP2ClusterMount-z-wpcp22-01States2wsc4
CCEBP2ClusterZone-z-wpcp22States2wsc4

What I was hoping for was the file tabulated into neat columns (probably using the spaces as delimiters)

---------- Post updated at 07:48 AM ---------- Previous update was at 07:45 AM ----------

*NOTE* on my last post - the file I am using as input has staggered rows with spaces in between - NOT concateneated as has appeared in the paste above - sorry! But the output is concatenated as I said.

Last edited by Franklin52; 05-01-2012 at 10:23 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

use of format file to extract columns from a source file

hi experts lets say my format file is B B ========= column no,name,type,length 1,ee,N,12 3,hj,N.4 4,kl,N,5 source file ======== d e f g h i 5 8 9 7 6 5 1 3 4 5 6 6 (2 Replies)
Discussion started by: subhendu81
2 Replies

2. Shell Programming and Scripting

Format a text file

I have a file that gets created by pasting 3 files together to get the one file. The output of the 3 files follows. sft.rtf c3_critappdb_u5 start 04:22:20 end 08:03:41 c3_critappdb_u6 start 18:01:31 end 20:21:19 c3_critappdb_u7 start 00:02:50 end 08:30:17 c3_critappdb_u8 start 17:00:42 end... (2 Replies)
Discussion started by: jhardy
2 Replies

3. Shell Programming and Scripting

Changing the text file format

Hi, I have a shell script to unload all the empname who have salary >50000 from the emp table into a text file(empname.txt) . m_db unload "$dbc_file" -column_delimiter ',' -select "SELECT empname FROM emp where salary > 50000" >> empname.txt Now my text file have data in the following format ... (3 Replies)
Discussion started by: kavithakuttyk
3 Replies

4. Shell Programming and Scripting

Uniform length for all the lines in file

Hi, I have a file with different width for each line. like first line with 45characters and second line of 30 characters. But I want to make all the lines to 45 characters in file. Appreciate your inputs Thanks Arun: (1 Reply)
Discussion started by: arund_01
1 Replies

5. Shell Programming and Scripting

format text file

i have a text file in this format: name1^A1^B1^ name2^A2^B2^ ... namex^Ax^Bx^ name1^AA1^ name2^AA2^ ... namex^AAx^ name1^AAA1^BBB1^ name2^AAA1^BBB2^ ... namex^AAAx^BBBx^ name1^AAAA1^ name2^AAAA2^ ... namex^AAAAx^ i want to generate a file: (2 Replies)
Discussion started by: busystock
2 Replies

6. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

7. Shell Programming and Scripting

Conversion of spaces Text file into CSV format file

Input file (each line is separaed by spaces )given below: Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- -----... (18 Replies)
Discussion started by: sreenath1037
18 Replies

8. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

9. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies

10. Shell Programming and Scripting

Format text file to html

Hi Experts, Anybody out there figure out on how to achieve in shell scripts or tools. I have done googling to find solutions but no luck. I have thousands of .txt files to batch process, please see the below sample text content after -------- start here --------. What I want to achieve is to... (10 Replies)
Discussion started by: lxdorney
10 Replies
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. Please notice this option isn't related to the terminal length as in a "80 culums terminal". --font=desc Set the font description. Default is Monospace 12. --rtl Do right to left (RTL) layout. --paper ps Choose paper size. Known paper sizes are legal, letter and A4. Default is A4. Postscript points Each postscript point equals to 1/72 of an inch. 36 points are 1/2 of an inch. --bottom-margin=bm Set bottom margin. Default is 36 postscript points. --top-margin=tm Set top margin. Default is 36 postscript points. --left-margin=lm Set left margin. Default is 36 postscript points. --right-margin=rm Set right margin. Default is 36 postscript points. --gutter-width=gw Set gutter width. Default is 40 postscript points. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 04:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy