How to format output in columns by appending multi lines one by one?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to format output in columns by appending multi lines one by one?
# 8  
Old 05-05-2014
Try :

Code:
$ cat file
Customer : Apr 24 16:31 Customer_Name_111121.txt
Apr 24 16:32 Customer_Name _111121. txt
Apr 24 16:34 Customer_Name_111112. txt
Apr 24 16:35 Customer_Name _222223. txt
Apr 24 16:37 Customer_Name_999999. txt
Brain-UCG : Apr 24 16:35 User_config_20140107.dat
Apr 24 16:36 User_config_20140110.dat
Apr 24 16:36 User_config_20140109.dat

Code:
$ awk --re-interval '/^[[:alpha:]]{3}[[:space:]][[:digit:]]{2}/{$0="\t "$0}1' file
Customer : Apr 24 16:31 Customer_Name_111121.txt
	 Apr 24 16:32 Customer_Name _111121. txt
	 Apr 24 16:34 Customer_Name_111112. txt
	 Apr 24 16:35 Customer_Name _222223. txt
	 Apr 24 16:37 Customer_Name_999999. txt
Brain-UCG : Apr 24 16:35 User_config_20140107.dat
	 Apr 24 16:36 User_config_20140110.dat
	 Apr 24 16:36 User_config_20140109.dat

---------- Post updated at 10:29 PM ---------- Previous update was at 10:26 PM ----------

Or use sprintf
Code:
$ awk --re-interval '/^[[:alpha:]]{3}[[:space:]][[:digit:]]{2}/{$0=sprintf("%13s"," ")$0}1'

This User Gave Thanks to Akshay Hegde For This Post:
# 9  
Old 05-07-2014
Hi Akshay,

Thats what i am looking for.....Thakyou so much.
Only one small help,could you please explain me how does it works???.

Thanks
ketanr
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split multi columns line to 2 columns

I have data like this 1 a,b,c 2 a,c 3 b,d 4 e,f would like convert like this 1 a 1 b 1 c 2 a 2 c 3 b 3 d 4 e 4 f Please help me out (4 Replies)
Discussion started by: jhonnyrip
4 Replies

2. Shell Programming and Scripting

Sum of columns and format the output

Input file: 011100020100 0.00 1 20000 30000 20000 011110000025 0.00 1 000 240000 10000 011100020100 0.00 1 200000 2324000 403500 032200030025 0.00 1 2077500 3077500 250000 032200030025 0.00 1 2565000 25536400 320000 022220000005 0.00 1 10000 300000 300000 022220000005 0.00 1 200050... (7 Replies)
Discussion started by: vinus
7 Replies

3. Shell Programming and Scripting

Format output into columns, variables with multiple entries

Hello all, I've got a script that collects data on file systems and prints out specific data about each. I've formatted headers w/ printf like so. printf "\033 and I had the content of the varibles printed out beneath those columns like so: printf... (5 Replies)
Discussion started by: awreneau
5 Replies

4. UNIX for Dummies Questions & Answers

Appending columns at the end of output using awk/sed

Hi , I have the below ouput, =====gopi===== assasassaa adsadsadsdsada asdsadsadasdsa sadasdsadsd =====kannan=== asdasdasd sadasddsaasd adasdd =====hbk=== asasasssa .... .. I want the output like as below, not able paste here correctly. (2 Replies)
Discussion started by: eeegopikannan
2 Replies

5. Shell Programming and Scripting

incrementing lines in the file & format output.

Hi All, I need read the file and out put format as below using ksh, I wrote below script its keep on repeating first line in the file. may i know the best way to get the below out put while incrementing line in the file. cat b.txt |awk '{print $0}' |while read line do aa=`cat $line |head -1... (7 Replies)
Discussion started by: ashanabey
7 Replies

6. Shell Programming and Scripting

Appending the last few columns to the front

Hi consider this as the first line 00010015 MORGAN STANLEY & CO INCORPORATED N 110 INVESTAR 1 0001OT NJ 201-830-5055 01-Jan-1974 00:00:00 1 01-May-2008 00:00:00 05-Jun-2008 13:34:18 0001 - From SMSRun1_GIDQA02 Consider this as the second line 00010015 MORGAN STANLEY... (3 Replies)
Discussion started by: ragavhere
3 Replies

7. Shell Programming and Scripting

Cronjob - Redirect mail output to file, LINES & COLUMNS

I currently have an expect script that issues the 'mail' command and sends an 'x' when it receives the & prompt from mail to quit. The expect script is able to do stty rows 100 columns 200 < $spawn_out(slave,name) to set up the number of columns and rows. I would like to get rid of the expect... (0 Replies)
Discussion started by: jharvey
0 Replies

8. UNIX for Dummies Questions & Answers

To convert multi format file to a readable ascii format

Hi I have a file which has ascii , binary, binary decimal coded,decimal & hexadecimal data with lot of special characters (like öƒ.ƒ.„İİ¡Š·œƒ.„İİ¡Š· ) in it. I want to standardize the file into ASCII format & later use that as source . Can any one suggest a way a logic to convert such... (5 Replies)
Discussion started by: gaur.deepti
5 Replies

9. Shell Programming and Scripting

need help appending lines/combining lines within a file...

Is there a way to combine two lines onto a single line...append the following line onto the previous line? I have the following file that contains some blank lines and some lines I would like to append to the previous line... current file: checking dsk c19t2d6 checking dsk c19t2d7 ... (2 Replies)
Discussion started by: mr_manny
2 Replies

10. Shell Programming and Scripting

Appending columns on a file

My issue is the following: I have several text files, let's say 10 of them. Each one has three columns separated by a tab: Date, Time and Value. What I want to do next is to have only one text file containing the information: Date, Time, Value1, Value2, Value3, ... , Value10, where Value1... (2 Replies)
Discussion started by: abel
2 Replies
Login or Register to Ask a Question