Sponsored Content
Top Forums Shell Programming and Scripting Awk/sed script for transposing any number of rows with header row Post 302798555 by tntelle on Wednesday 24th of April 2013 04:50:25 PM
Old 04-24-2013
Thank you Yoda! This worked like a charm. There was something I forgot to mention that you'll probably know how to address... what if one of the values in the header is something like "PLANET" and I want to tack on whatever that planet is to the front of every line. So for instance:


Row1: (header) Letter, Weight, Color, Cost, PLANET
Row2: A, 20, Blue, 5, MARS
Row3: DD, 200, Orange, 100, REMULAK
... (and so forth)

We now get:

MARS, Letter,A
MARS, Weight,20
MARS, Color,Blue
MARS, Cost,5

REMULAK, Letter,DD
REMULAK, Weight,200
REMULAK, Color,Orange
REMULAK, Cost,100


Thank you Master... Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED: delete matching row and 4 next rows?

Hi, Tried to look for solution, and found something similar but could not adapt the solution for my needs.. I'm trying to match a pattern (in this case "ProcessType")in a logfile, then delete that line and the 4 following lines. The logfile looks as follows: ProcessType: PROCESS_A... (5 Replies)
Discussion started by: Juha
5 Replies

2. Shell Programming and Scripting

shell script(Preferably awk or sed) to print selected number of columns from each row

Hi Experts, The question may look very silly by seeing the title, but please have a look at it clearly. I have a text file where the first 5 columns in each row were supposed to be attributes of a sample(like sample name, number, status etc) and the next 25 columns are parameters on which... (3 Replies)
Discussion started by: ks_reddy
3 Replies

3. Shell Programming and Scripting

how to add the number of row and count number of rows

Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count The input file: 21 2341 A 21 2341 A 21 2341 A 21 2341 C 21 2341 C 21 2341 C 21 2341 C 21 4567 A 21 4567 A 21 4567 C ... (6 Replies)
Discussion started by: juelillo
6 Replies

4. Shell Programming and Scripting

awk, string as record separator, transposing rows into columns

I'm working on a different stage of a project that someone helped me address elsewhere in these threads. The .docs I'm cycling through look roughly like this: 1 of 26 DOCUMENTS Copyright 2010 The Age Company Limited All Rights Reserved The Age (Melbourne, Australia) November 27, 2010... (9 Replies)
Discussion started by: spindoctor
9 Replies

5. Shell Programming and Scripting

Combining multiple rows in single row based on certain condition using awk or sed

Hi, I'm using AIX(ksh shell). > cat temp.txt "a","b",0 "c",bc",0 "a1","b1",0 "cc","cb",1 "cc","b2",1 "bb","bc",2 I want the output as: "a","b","c","bc","a1","b1" "cc","cb","cc","b2" "bb","bc" I want to combine multiple lines into single line where third column is same. Is... (1 Reply)
Discussion started by: samuelray
1 Replies

6. UNIX for Dummies Questions & Answers

append column and row header to a file in awk script.

Hi! Is there a way to append column and row header to a file in awk script. For example if I have Jane F 39 manager Carlos M 40 system administrator Sam F 20 programmer and I want it to be # name gend age occup 1 Jane F 39 manager 2 Carlos M ... (4 Replies)
Discussion started by: FUTURE_EINSTEIN
4 Replies

7. Shell Programming and Scripting

Match in awk skipping header rows

I am trying to match $1-$7 between the two files and if a match is found then the contents of $8 in file2 and copied over. The awk I tried is below. There is also a header row in file2 that has the Chr Start End Ref Alt that does not need to be searched. Thank you :). awk awk... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

At text to field 1 of header row using awk

I am just trying to insert the word "Index" using awk. The below is close but seems to add the word at the end and I can not get the syntax correct to add from the beginning. Thank you :). awk -F'\t' -v OFS='\t' '{ $-1=$-1 OFS "Index"}$1=$1' file current output Chr Start End ... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

awk to skip header row and add string to field

The awk below does put in VUS in the 9th field but I can not seem to skip the header then add the VUS. I tried to incorporate NR >=2 and NR > 1 with no luck. Thank you :). input Chr Start End Ref Alt Func.refGene PopFreqMax CLINSIG Classification chr1 43395635 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. Shell Programming and Scripting

Reseting row count every given number of rows

I have a file with 48 rows. I am counting 6 rows and adding 6 to that number and repeating the operation, and then output the value in column 1. For the second column, I would like to get sort of a binary output (1s and 2s) every 3rd row. This is what I have: awk '{print ++src +... (1 Reply)
Discussion started by: Xterra
1 Replies
Color::Library::Dictionary::Tango(3pm)			User Contributed Perl Documentation		    Color::Library::Dictionary::Tango(3pm)

NAME
Color::Library::Dictionary::Tango - (Tango) The Tango color palette DESCRIPTION
The Tango icon theme's goal is to make applications not seem alien on any desktop. A user running a multiplatform application should not have the impression that the look is unpolished and inconsistent with what he or she is used to. While this isn't about merging styles of all desktop systems, we do aim to not be drastically different on each platform. The Tango color palette consists of 27 RGB colors. <http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines> COLORS
Aluminium 1 aluminium1 #eeeeec Aluminium 2 aluminium2 #d3d7cf Aluminium 3 aluminium3 #babdb6 Aluminium 4 aluminium4 #888a85 Aluminium 5 aluminium5 #555753 Aluminium 6 aluminium6 #2e3436 Butter 1 butter1 #fce94f Butter 2 butter2 #edd400 Butter 3 butter3 #c4a000 Chameleon 1 chameleon1 #8ae234 Chameleon 2 chameleon2 #73d216 Chameleon 3 chameleon3 #4e9a06 Chocolate 1 chocolate1 #e9b96e Chocolate 2 chocolate2 #c17d11 Chocolate 3 chocolate3 #8f5902 Orange 1 orange1 #fcaf3e Orange 2 orange2 #f57900 Orange 3 orange3 #ce5c00 Plum 1 plum1 #ad7fa8 Plum 2 plum2 #75507b Plum 3 plum3 #5c3566 Scarlet Red 1 scarletred1 #ef2929 Scarlet Red 2 scarletred2 #cc0000 Scarlet Red 3 scarletred3 #a40000 Sky Blue 1 skyblue1 #729fcf Sky Blue 2 skyblue2 #3465a4 Sky Blue 3 skyblue3 #204a87 perl v5.14.2 2011-12-07 Color::Library::Dictionary::Tango(3pm)
All times are GMT -4. The time now is 03:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy