how to arrange datas in columns in shell script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to arrange datas in columns in shell script.
# 1  
Old 08-15-2012
how to arrange datas in columns in shell script.

Hello All,

I have datas in the below format.

Mark 45
Steve 60
Johnson 79
Elizabeth 90

My requirement is to arrange the data in the order as shown in the attachment.
My OS is Solaris.

Image

Last edited by vashece; 08-15-2012 at 03:43 PM..
# 2  
Old 08-15-2012
The order doesn't look changed at all.

How about outputting with tabs?
Code:
awk '{$1=$1} 1' OFS="\t" inputfile > outputfile

# 3  
Old 08-15-2012
Try:
Code:
awk '{$1=sprintf ("%-10s",$1)}1' file

# 4  
Old 08-15-2012
Quote:
Originally Posted by bartus11
Try:
Code:
awk '{$1=sprintf ("%-10s",$1)}1' file


I have attached a screenshot of the desired output. Please have a look on it
# 5  
Old 08-15-2012
Did you try my solution?
# 6  
Old 08-16-2012
Or mine?
# 7  
Old 08-22-2012
Thanks Corona688 and Bartus11. Both the commands worked,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting - need to arrange the columns from multiple file into a single file

Hi friends please help me on below, i have 5 files like below file1 is x 10 y 20 z 15 file2 is x 100 z 245 file3 is y 78 z 23 file4 is x 100 (3 Replies)
Discussion started by: siva kumar
3 Replies

2. Shell Programming and Scripting

How to arrange xml tags in single row using shell script?

I want to put one xml record in one row and so on... sample two records are here. <?xml version="1.0"?> <Object> <Header> <XCOMVers>V1.0</XCOMVers> <REPORT>XXXXX</REPORT> <CODE>002</CODE> </Header> <IssueCard> <Record> <L>CAR SYSTEM -SSSSS -</L> ... (3 Replies)
Discussion started by: sene_geet
3 Replies

3. Shell Programming and Scripting

How to arrange xml tags in single row using shell script?

I want to put one xml record in one row and so on... sample two records are here. <?xml version="1.0"?> <Object> <Header> <XCOMVers>V1.0</XCOMVers> <REPORT>XXXXX</REPORT> <CODE>002</CODE> </Header> <IssueCard> <Record> <L>CAR SYSTEM -SSSSS -</L> ... (1 Reply)
Discussion started by: sene_geet
1 Replies

4. Shell Programming and Scripting

arrange files into columns

Hi may i ask how to arrange this file in into columns like example below Problem: #cat data.txt 1 2 3 4 5 a b c d 9 8 7 6 desired output (9 Replies)
Discussion started by: jao_madn
9 Replies

5. Shell Programming and Scripting

Arrange output based on rows into columns

Hi All, I would like to ask help on how can i achieve below output. Inputfile: Oct11,apa1-daily,01:25:01 Oct11,apa2-daily,01:45:23 Oct12,apa1-daily,02:30:11 Oct12,apa2-daily,01:55:01 Oct13,apa1-off,01:43:34 Oct13,apa2-off,01:22:04 Desired output: Clients ... (3 Replies)
Discussion started by: mars101
3 Replies

6. Shell Programming and Scripting

Shell script to arrange files into several folders

Hello this is the script Im working on I have a picture collection that I rescued from a hard drive and there are thousands of pictures saved in one folder. What I need is to create several folders and put lets say around 200 pictures in each folder. At the end instead of having one huge... (8 Replies)
Discussion started by: kizofilax
8 Replies

7. Shell Programming and Scripting

gawk - reading two files & re arrange the columns

Hi, I am trying to read 2 files and writing to the 3rd file if I find the same elements in 2 files. my first file is 1 0 kb12124819 766409 1.586e-01 1 0 kb17160939 773886 8.674e-01 1 0 kb4475691 836671 8.142e-01 1 0 ... (2 Replies)
Discussion started by: ezhil01
2 Replies

8. Shell Programming and Scripting

reading XML datas via Shell Script

Hi all, i have an xml file with this fomat(exactly) : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE TestSuite SYSTEM "../../CallCrt.dtd"> <TestSuite description="Diameter"> <FileReference FileName="DMI_FC01.xml"/> <!--<FileReference FileName="DMI_FC02.xml"/> -->... (1 Reply)
Discussion started by: freepal
1 Replies

9. Shell Programming and Scripting

Shell script to separte columns...

Hi all, I have a data file and need to load the data into tables in a database. The problem is I cannot use a while loop with each line as the data is free text and has all kinds of weird characters including carriage returns and new line characters. Each column is separated by ~^~ and a new line... (2 Replies)
Discussion started by: sam_78_nyc
2 Replies

10. Shell Programming and Scripting

re arrange the columns

Hi - can any one let me know how to re-arrange the columns of a comma seperated file. The problem here is that the colums some times have new lines and when the columns has new lines or extra comma's then it is enclosed in double quotes("). Can any one tell me how to re-arrange the columns now. ... (0 Replies)
Discussion started by: ahmedwaseem2000
0 Replies
Login or Register to Ask a Question