Re-arrange column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Re-arrange column
# 1  
Old 06-14-2010
Re-arrange column

10.142.7.155 - - [02/Jun/2010:01:22:07 -0700] www.abc.com 404 -

I have many columns which is tab delimited file, I have to re-arrange this to a particular column and also add "-" to 3rd column and 6th column.

10.142.7.155 - - - www.abc.com - 404 - [02/Jun/2010:01:22:07 -0700]
# 2  
Old 06-14-2010
Code:
awk '{print $1,$2,$3" -",$6" -",$7,$8,$4,$5}' infile

# 3  
Old 06-14-2010
Use awk command
Code:
awk ' { print $1, $2, $3, "-", $6 } ' file

Add other fields in the order you need
# 4  
Old 06-15-2010
awk '{print $1,$2,$3" -",$6" -",$7,$8,$4,$5}' file.txt column is splitted based based on the space. File.txt is the tab delimited file
# 5  
Old 06-15-2010
Quote:
Originally Posted by sandy1028
awk '{print $1,$2,$3" -",$6" -",$7,$8,$4,$5}' file.txt column is splitted based based on the space. File.txt is the tab delimited file
Code:
awk -F"\t" -vOFS="\t" '{print $1,$2,$3"\t-",$6"\t-",$7,$8,$4,$5}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Arrange data in table

Hello All, I have following data into my file named record. Name City phone number email Jhon Newyork 123456987 jhon@gmail.com Maria Texas 569865612 Maria_Sweet@rediffmail.com Chan Durben NA Chan123@gmail.com The output should be in straight columns.. There should not be any... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

2. Shell Programming and Scripting

How to words in arrange as Table

Hi Team, I have one file in that almost 100+ words in lines Eg:- Unix windows solaris Linux ... ... But I want arrange all lines in table format and can able read on screen Eg: - Unix windows solaris Lunix...... Hp unix Mac-os ...... Like as Table...... (11 Replies)
Discussion started by: Bhaskar Alagala
11 Replies

3. Shell Programming and Scripting

Arrange same data in same column ....

I have vary complex issue in unix...i want copy same data in same column... My Input... Object SpchAccate hAes hCCS SDop Sroontb NoRabEt SRbuc ran=C515D (Mod=15) 0 100 98.1 1.9 0.6 ... (7 Replies)
Discussion started by: asavaliya
7 Replies

4. Shell Programming and Scripting

sorting when i need to re-arrange

I have a directory with files of the form <name>_rpt_DDMMYY_HH24:00.html I need to list them by YYMMDD and I need to get the full name back. (1 Reply)
Discussion started by: guessingo
1 Replies

5. Shell Programming and Scripting

Arrange values of a column in row

HI, I need to arrange values of a colum in row. e.g. input file : Alpha<>123 AAAA<>6754 Beta<>456 BBBB<>63784 CCC<>783 Gama<>789 Alpha<>555 AAAA<>6754 BBBB<>63784 Beta<>666 CCC<>783 Gama<>888 (9 Replies)
Discussion started by: The_Archer
9 Replies

6. UNIX for Dummies Questions & Answers

How to arrange the files according to time

hi friends, m new to unix environment.. i want to know that "how could we arrange the various files in our unix system according to time at which they are accessed, and are there are ways that we can arrange them in ascending or descending manner..." please help me out with full details...... (4 Replies)
Discussion started by: adityamitra
4 Replies

7. UNIX for Dummies Questions & Answers

Arrange data

I have a following data: 100 200 300 400 I want the data to be arranged: 100 200 300 400 What is the best way to do this? Thanks! (5 Replies)
Discussion started by: bobo
5 Replies

8. Shell Programming and Scripting

arrange data tools

Which is the best command(s) to arrange data of a file? This is my example input file: Tom ------ apples: 5 oranges: 7 pears: 10 apples: 2 oranges: 8 Jack ------ apples: 3 pears: 10 Lucy ------ oranges: 1 pears: 8 peaches: 9 Tom ------ peaches: 1 Jack ------ (1 Reply)
Discussion started by: csecnarf
1 Replies

9. Shell Programming and Scripting

re arrange data

Any idea in awk or sed? $cat file a b c 2 4 5 6 output: a b c 2 4 5 6 (3 Replies)
Discussion started by: kenshinhimura
3 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