Sponsored Content
Top Forums Shell Programming and Scripting Convert row to columns start from nth column Post 302911990 by saurabh29may on Tuesday 5th of August 2014 04:37:24 AM
Old 08-05-2014
Hi All, I am new to this forum . I am struggling with one issue

I have record set like (fixed width file)
Code:
1HKG  BKK  20140425201
2HKG  BKK  20140425201
3HKG  BKK  20140425201
1SIN  KUL  20140414201
2SIN  KUL  20140414201
3SIN  KUL  20140414201
1HKG  BKK  20140427201
2HKG  BKK  20140427201
3HKG  BKK  20140427201
1HKG  BKK  20140424201
2HKG  BKK  20140424201
3HKG  BKK  20140424201
1CDG  PVG  20140414201
2CDG  PVG  20140414201
3CDG  PEK  20140414201
3PEK  PVG  20140415201
1YYZ  BLR  20140414201
2YYZ  BLR  20140414201
3YYZ  FRA  20140414201
3FRA  BLR  20140415201
1BKK  CDG  20140409201

so there will be only 1,2,3 value in first field i need to assign seq number and output like this

Code:
1 1HKG  BKK  20140425201
1 2HKG  BKK  20140425201
1 3HKG  BKK  20140425201
2 1SIN  KUL  20140414201
2 2SIN  KUL  20140414201
2 3SIN  KUL  20140414201
3 1HKG  BKK  20140427201
3 2HKG  BKK  20140427201
3 3HKG  BKK  20140427201
4 1HKG  BKK  20140424201
4 2HKG  BKK  20140424201
4 3HKG  BKK  20140424201
5 1CDG  PVG  20140414201
5 2CDG  PVG  20140414201
5 3CDG  PEK  20140414201
5 3PEK  PVG  20140415201
6 1YYZ  BLR  20140414201
6 2YYZ  BLR  20140414201
6 3YYZ  FRA  20140414201

Please help

Last edited by Don Cragun; 08-05-2014 at 06:29 AM.. Reason: Add missing CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

convert matrix to row and columns

Dear Unix Gurus, I have a sample data set that looks like this y1 y2 y3 y4 y5 x1 0.3 0.5 2.3 3.1 5.1 x2 1.2 4.1 3.5 1.7 1.2 x3 3.1 2.1 1.0 4.1 2.1 x4 5.0 4.0 6.0 7.0 1.1 I want to open it up so that I get x1 y1 0.3 x2 y1 1.2 x3 y1 3.1 x4 y1 5.0 x1 y2 0.5 x2 y2... (3 Replies)
Discussion started by: tintin72
3 Replies

2. Shell Programming and Scripting

How to convert 2 column data into multiple columns based on a keyword in a row??

Hi Friends I have the following input data in 2 columns. SNo 1 I1 Value I2 Value I3 Value SNo 2 I4 Value I5 Value I6 Value I7 Value SNo 3 I8 Value I9 Value ............... ................ SNo N (1 Reply)
Discussion started by: ks_reddy
1 Replies

3. Shell Programming and Scripting

Convert columns to single row

Hello all I have data like 1 2 3 4 5 I wish my output would be like 1,2,3,4,5 For this i have executed 'BEGIN {FS="\n"; ORS=","} {print $0}' test and got the output as 1,2,3,4,5, I do not want to have , at the end of 5. output should be like (5 Replies)
Discussion started by: vasuarjula
5 Replies

4. Shell Programming and Scripting

convert a column to row output?

Getting tired of cut-and-paste...so I thought I would post a question. how do I change this column output to a single row? from this: # vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}' /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5... (8 Replies)
Discussion started by: mr_manny
8 Replies

5. Shell Programming and Scripting

Convert row to column

Hi, I have a file like this 50 1 2 1374438 50 1 2 1682957 50 5 2 1453574 50 10 2 1985890 100 1 2 737307 100 5 2 1660204 100 10 2 2148483 and I want to convert this by... (1 Reply)
Discussion started by: gvj
1 Replies

6. UNIX for Dummies Questions & Answers

Dividing all columns by the nth row

Hi All! if I have a file like this: 8 10 12 14 16 18 0 2 6 2 4 6 8 10 12 16 18 10 6 8 12 16 18 0 2 2 6 2 2 2 2 2 2 2 2 2 10 12 16 4 8 16 4 16 0 8 10 14 16 0 4 8 12 14 And I want to divide all the lines by line 4 for example... (6 Replies)
Discussion started by: cosmologist
6 Replies

7. Shell Programming and Scripting

convert row to column with respect of first column.

Input file A.txt :- C2062 -117.6 -118.5 -117.5 C5145 0 0 0 C5696 0 0 0 Output file B.txt C2062 X -117.6 C2062 Y -118.5 C2062 Z -117.5... (4 Replies)
Discussion started by: asavaliya
4 Replies

8. Shell Programming and Scripting

Convert columns to row using awk

Hi I need to convert some columns form a html file to rows. I do manage to make it works without help (some proud :) ) For some reason the offline status is not in bold, so I do need to remove the <b> tag from the other field to make this to work. All fields are not needed, so I test and... (5 Replies)
Discussion started by: Jotne
5 Replies

9. Shell Programming and Scripting

How to convert the row to column in Perl?

Dear Perl users, Could you help me how to convert from row to column if I've a case below: Linux 2014_01_24 CPU 10 Linux 2014_01_24 MEM 20 UNIX 2014_01_24 CPU 30 UNIX 2014_01_24 MEM ... (6 Replies)
Discussion started by: askari
6 Replies

10. Shell Programming and Scripting

Convert Data from Column to Row

Hi FileA.txt E_TIM 16, ETE 15, EOND 26, EEC 81, E_1 un, E_2 un, E_3 un, E_4 284, E_TIM 17, ETE 15, EOND 29, EEC 82, E_1 un, E_2 un, E_3 un, E_4 249, (6 Replies)
Discussion started by: asavaliya
6 Replies
COLRM(1)						    BSD General Commands Manual 						  COLRM(1)

NAME
colrm -- remove columns from a file SYNOPSIS
colrm [start [stop]] DESCRIPTION
The colrm utility removes selected columns from the lines of a file. A column is defined as a single character in a line. Input is read from the standard input. Output is written to the standard output. If only the start column is specified, columns numbered less than the start column will be written. If both start and stop columns are spec- ified, columns numbered less than the start column or greater than the stop column will be written. Column numbering starts with one, not zero. Tab characters increment the column count to the next multiple of eight. Backspace characters decrement the column count by one. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of colrm as described in environ(7). EXIT STATUS
The colrm utility exits 0 on success, and >0 if an error occurs. SEE ALSO
awk(1), column(1), cut(1), paste(1) HISTORY
The colrm command appeared in 3.0BSD. BSD
August 4, 2004 BSD
All times are GMT -4. The time now is 04:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy