Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Transpose rows to certain columns Post 303030378 by rahman.ahmed on Friday 8th of February 2019 01:56:03 PM
Old 02-08-2019
Hi,

Actually I don't have much experience in using awk. I got as far as transposing the columns and stuck there.

I used this
Code:
cat boxes.txt
Box Name: BoxA
Weight: 1
Length :2
Depth :3
Color: red
Box Name: BoxB
Weight: 3
Length :4
Color: Yellow
Box Name: BoxC
Weight: 5
Length :6
Depth :7
Box Name: BoxD
Weight: 8
Length :9

Code:
cat boxes.txt | awk '/^Box/ && c{print c;c=""}{c=c $0" "}END{if(c) print c}'
Box Name: BoxA Weight: 1 Length :2 Depth :3 Color: red
Box Name: BoxB Weight: 3 Length :4 Color: Yellow
Box Name: BoxC Weight: 5 Length :6 Depth :7
Box Name: BoxD Weight: 8 Length :9

I read the related threads in this forum but didn't find what I am looking for since the data is not identical for each row.

Thanks,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rows to Columns - File Transpose

Hi I have an input file and I want to transpose it but I need to take care that if any field is missing for a record it should be popoulated with space for that field - using a shell script INFILE ---------- emp=1 sal=2 loc=abc emp=2 sal=21 sal=22 loc=xyz emp=5 loc=abc OUTFILE... (10 Replies)
Discussion started by: 46019
10 Replies

2. Shell Programming and Scripting

Transpose multipe columns to rows and adding headers

Hi, I found the following awk script to transpose multiple (3) columns to multiple rows: #=== BEGIN {FS=","} { for (i=1;i<=NF;i++) { arr=$i; if(nf<= NF) nf=NF; } nr=NR } END { for(i=1;i<=nf;i++) { (8 Replies)
Discussion started by: Gery
8 Replies

3. Shell Programming and Scripting

Transpose columns to Rows : Big data

Hi, I did read a few posts on the subjects, tried out a few solutions, but did not solve my problem. https://www.unix.com/302121568-post11.html https://www.unix.com/shell-programming-scripting/137953-large-file-columns-into-rows-etc-4.html Please help. Problem very similar to the second link... (15 Replies)
Discussion started by: genehunter
15 Replies

4. Shell Programming and Scripting

Transpose Rows Into Columns

I'm aware there are a lot of resources dedicated to the question of transposing rows and columns, but I'm a total newbie at this and the task appears to be beyond me. I have 40 text files with content that looks like this: Dokument 1 von 146 Orange County Register (California) June 26, 2010... (2 Replies)
Discussion started by: spindoctor
2 Replies

5. Shell Programming and Scripting

Transpose columns to Rows

I have a data A 1 B 2 C 3 D 4 E 5 i would like to change the data A B C D E 1 2 3 4 5 Pls suggest how we can do it in UNIX. Start using code tags, thanks. Also start reading your PM's you get from Mods as well read the Forum Rules. That might not do any harm. (24 Replies)
Discussion started by: aravindj80
24 Replies

6. Shell Programming and Scripting

transpose rows to columns

Any tips on how I can awk the input data to display the desired output per below? Thanking you in advance. input test data: 2 2010-02-16 10:00:00 111111111111 bytes 99999999999 bytes 90% 4 2010-02-16 12:00:00 333333333333 bytes 77777777777 bytes 88% 5 2010-02-16 11:00:00... (4 Replies)
Discussion started by: ux4me
4 Replies

7. Shell Programming and Scripting

Transpose Data from Columns to rows

Hello. very new to shell scripting and would like to know if anyone could help me. I have data thats being pulled into a txt file and currently have to manually transpose the data which is taking a long time to do. here is what the data looks like. Server1 -- Date -- Other -- value... (7 Replies)
Discussion started by: Mikes88
7 Replies

8. Shell Programming and Scripting

Columns to Rows - Transpose - Special Condition

Hi Friends, Hope all is well. I have an input file like this a gene1 10 b gene1 2 c gene2 20 c gene3 10 d gene4 5 e gene5 6 Steps to reach output. 1. Print unique values of column1 as column of the matrix, which will be a b c (5 Replies)
Discussion started by: jacobs.smith
5 Replies

9. Shell Programming and Scripting

awk to transpose every 7 rows into columns

input: a1 a2 a3 a4 a5 a6 a7 b1 b2 b3 .. b7 .. z1 .. z7 (12 Replies)
Discussion started by: ux4me
12 Replies

10. Shell Programming and Scripting

Transpose rows to columns complex

Input: IN,A,1 IN,B,3 IN,B,2 IN,C,7 BR,A,1 BR,A,5 BR,C,9 AR,C,9 Output: CNTRY,A,B,C IN,1,5,7 BR,6,0,9 AR,0,0,9 (7 Replies)
Discussion started by: unme
7 Replies
Mail::Box::Locker::Mutt(3pm)				User Contributed Perl Documentation			      Mail::Box::Locker::Mutt(3pm)

NAME
Mail::Box::Locker::Mutt - lock a folder using mutt_dotlock INHERITANCE
Mail::Box::Locker::Mutt is a Mail::Box::Locker is a Mail::Reporter SYNOPSIS
See Mail::Box::Locker DESCRIPTION
The "mutt" mail reader includes an separate program which is specialized in locking folders. This locker class uses this external program. Mutt is not automatically installed. METHODS
$obj->exe() Returns the name of the external binary. Constructors Mail::Box::Locker::Mutt->new(OPTIONS) -Option --Defined in --Default exe mutt_dotlock expires Mail::Box::Locker 1 hour file Mail::Box::Locker undef folder Mail::Box::Locker <undef> log Mail::Reporter 'WARNINGS' method Mail::Box::Locker 'DOTLOCK' timeout Mail::Box::Locker 10 seconds trace Mail::Reporter 'WARNINGS' exe => PATH The name of the program. May be a relative or absolute path. expires => SECONDS file => FILENAME folder => FOLDER log => LEVEL method => STRING|CLASS|ARRAY timeout => SECONDS|'NOTIMEOUT' trace => LEVEL The Locker $obj->filename([FILENAME]) See "The Locker" in Mail::Box::Locker $obj->folder([FOLDER]) See "The Locker" in Mail::Box::Locker $obj->name() See "The Locker" in Mail::Box::Locker Locking $obj->hasLock() See "Locking" in Mail::Box::Locker $obj->isLocked() See "Locking" in Mail::Box::Locker $obj->lock() $obj->unlock() Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Box::Locker::Mutt->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Box::Locker::Mutt->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Box::Locker::Mutt->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Box::Locker $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DIAGNOSTICS
Warning: Couldn't remove mutt-unlock $folder: $! Error: Failed to remove expired mutt-lock $lockfile: $! Warning: Folder $folder already mutt-locked Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. Warning: Removed expired mutt-lock $lockfile SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Box::Locker::Mutt(3pm)
All times are GMT -4. The time now is 09:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy