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
FOOMATIC-PPD-OPTIONS(1) 				      General Commands Manual					   FOOMATIC-PPD-OPTIONS(1)

NAME
foomatic-ppd-options - show the PPD options SYNOPSIS
foomatic-ppd-options [-d=debuglevel] [ ppdfiles ] DESCRIPTION
The foomatic-ppd-options program reads the specified PPD files or stdin and decodes the PPD file to produce a list of options. This is really just a text based version of other print configuration tools. The output format consists of a set of lines, each starting with a keyword, followed by a set of options and the default value. For exam- ple: makemodel = Tektronix Phaser 350 Foomatic/Postscript (recommended) name=PageSize; default=Letter; options=Letter (US Letter), A4 (A4), 11x17 (11x17), A3 (A3), A5 (A5), B5 (B5 (JIS)),... name=PageRegion; default=Letter; options=Letter (US Letter), A4 (A4), ... Each option starts with the name tag, followed by a default value (if any), followed by the set of options and a comment describing them. Punctuation in the comment is escaped. Options -ddebuglevel Set the debug level. 0 disables debug messages. [ files ] The list of PPD files to read for options. A '-' causes STDIN to be read. EXIT STATUS
foomatic-ppd-options exits with a 0 status if successful, and nonzero if an error. An error message is also printed on standard error (STDERR). AUTHOR
Patrick Powell <papowell at astart.com> BUGS
Probably. But it has been tested. Foomatic Project 2003-09-16 FOOMATIC-PPD-OPTIONS(1)
All times are GMT -4. The time now is 07:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy