Sponsored Content
Top Forums Shell Programming and Scripting Convert Columns in Rows delimited by a strings Post 302889040 by Yoda on Tuesday 18th of February 2014 12:01:08 PM
Old 02-18-2014
Here is something I wrote based on your input data:
Code:
awk '
        BEGIN {
         print "UserName|DNSHostName|Caption|OSArchitecture|SerialNumber|NumberOfProcessors|TotalVisibleMemorySize|IPAddress|Name|Name|Description"
         n = split ( "UserName:DNSHostName:Caption:OSArchitecture:SerialNumber:NumberOfProcessors:TotalVisibleMemorySize:IPAddress", V, ":" )
         while ( ++k <= n )
               H[V[k]]
        }
        /UserName/ {
                f = 0
                c = 0
                split ( "", R )
        }
        function getval(par, str)
        {
                if ( par == "IPAddress" )
                        gsub ( /\{\"|\".*/, X, str )
                return str
        }
        /^Name/ {
                getline
                N[++c] = $0
                next
        }
        $1 in H {
                i = $1
                getline
                if ( !( $1 in H ) )
                {
                        if ( $1 != "Name" )
                                R[i] = getval( i, $0 )
                }
                else
                {
                        i = $1
                        getline
                        if ( $1 != "Name" )
                                R[i] = getval( i, $0 )
                }
                next
        }
        /Description/ {
                f = 1
                next
        }
        f && !/Description/ {
                for ( j = 1; j <= n; j++ )
                        printf "%s|", R[V[j]]
                printf "%s|%s|", N[1], N[2]
                printf "%s\n", $0
        }
' OFS='|' file

Feel free to make changes as per your requirement.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to convert columns to rows

Hi, I need a shell script for below requirement Input file P1 - 173310 P2 - 173476 P3 - 173230 P4 - 172737 P1 - 173546 P2 - 173765 P3 - 173876 P4 - 172989 Out put file P1 173310 173546 P2 173476 173765 P3 173230 173876 P4 172737 172989 Suresh (6 Replies)
Discussion started by: suresh3566
6 Replies

2. Shell Programming and Scripting

So I converted columns to rows but I want it to be tab delimited and also I want.....

Hi, So my file looks like this: title number JR 2 JR 2 JR 4 JR 5 NM 5 NM 8 NM 2 NM 8 I used this line that I wrote to convert it to rows so it will look like this: awk -F"\t" '!/^$/{a=a" "$3} END {for ( i in a) {print i,a}}' occ_output.tab > test.txt JR 2 2 4 5 NM 5 8... (4 Replies)
Discussion started by: kylle345
4 Replies

3. Shell Programming and Scripting

convert columns into rows

hi, Apologies if this has been covered. I have requirement where i have to convert a single column into multiple column. My data will be like this - 2 3 4 5 6 Output required - 2 3 4 5 6 (1 Reply)
Discussion started by: Nishithinfy
1 Replies

4. Shell Programming and Scripting

Convert Rows to Space Delimited Line

Hello, I would like to convert a list of rows to a space separated line. Any ideas? Input file: "Administration Tools" "Design Suite" "Dial-up Networking Support" "Editors" desired output "Administration Tools" "Design Suite" "Dial-up Networking Support" "Editors" Thanks,... (4 Replies)
Discussion started by: jaysunn
4 Replies

5. Shell Programming and Scripting

convert rows to columns

hi, i have the file as below: abc def ghi jkl i want the output as abc,def,ghi,jki please reply, Thanks (4 Replies)
Discussion started by: namitai
4 Replies

6. Shell Programming and Scripting

Convert few columns to rows

Hi! Does anybody help me in converting following data: INPUT looks like this: 20. 100. 30 200. 40. 400. 50. 100. 60. 200. 70. 400. 80. 200. 150. 210. 30. 100. OUTPUT should look like this: 20. 100. 30 200. 40. 400. 50. 100. 60. 200. 70.... (5 Replies)
Discussion started by: lovelinux
5 Replies

7. Shell Programming and Scripting

Convert Rows to Columns

Hi Everyone, Could someone shed some lights on how to convert the records in rows form into column basis. 172.29.59.12 IBM,8255-E8B 102691P 8 65536 MB 6100-04-11-1140 172.29.59.15 IBM,8255-E8B 102698P 4 45056 MB 6100-04-11-1140 IP SYS MODEL ... (6 Replies)
Discussion started by: ckwan
6 Replies

8. Shell Programming and Scripting

Convert rows to columns

I am looking to print the data in columns and after every 3 words it should be a new row. cat example.out | awk 'END { for (i = 0; ++i < m;) print _;print _ }{ _ = _ x ? _ OFS $1 : $1}' m=1| grep -i INNER I am looking to print in a new line after every 3 words. ... (2 Replies)
Discussion started by: lazydev
2 Replies

9. Shell Programming and Scripting

Convert rows to columns

hi folks, I have a sample data like what is shown below: 1,ID=1000 1,Org=CedarparkHospital 1,cn=john 1,sn=doe 1,uid=User001 2,uid=User002 2,ID=2000 2,cn=steve 2,sn=jobs 2,Org=Providence I would like to convert it into the below format: 1,1000,CedarparkHospital,john,doe,User001... (11 Replies)
Discussion started by: vskr72
11 Replies

10. Shell Programming and Scripting

Transpose comma delimited data in rows to columns

Hello, I have a bilingual database with the following structure a,b,c=d,e,f The right half is in a Left to right script and the second is in a Right to left script as the examples below show What I need is to separate out the database such that the first word on the left hand matches the first... (4 Replies)
Discussion started by: gimley
4 Replies
wxAuiNotebook(3erl)					     Erlang Module Definition					       wxAuiNotebook(3erl)

NAME
wxAuiNotebook - See external documentation: wxAuiNotebook. DESCRIPTION
See external documentation: wxAuiNotebook . This class is derived (and can use functions) from: wxControl wxWindow wxEvtHandler DATA TYPES
wxAuiNotebook() : An object reference, The representation is internal and can be changed without notice. It can't be used for comparsion stored on disc or distributed for use on other nodes. EXPORTS
new() -> wxAuiNotebook() See external documentation . new(Parent::wxWindow() (see module wxWindow)) -> wxAuiNotebook() Equivalent to new(Parent, []) . new(Parent::wxWindow() (see module wxWindow), Options::[Option]) -> wxAuiNotebook() Types Option = {id, integer()} | {pos, {X::integer(), Y::integer()}} | {size, {W::integer(), H::integer()}} | {style, integer()} See external documentation . addPage(This::wxAuiNotebook(), Page::wxWindow() (see module wxWindow), Caption::string()) -> bool() Equivalent to addPage(This, Page, Caption, []) . addPage(This::wxAuiNotebook(), Page::wxWindow() (see module wxWindow), Caption::string(), Options::[Option]) -> bool() Types Option = {select, bool()} | {bitmap, wxBitmap() (see module wxBitmap)} See external documentation . create(This::wxAuiNotebook(), Parent::wxWindow() (see module wxWindow)) -> bool() Equivalent to create(This, Parent, []) . create(This::wxAuiNotebook(), Parent::wxWindow() (see module wxWindow), Options::[Option]) -> bool() Types Option = {id, integer()} | {pos, {X::integer(), Y::integer()}} | {size, {W::integer(), H::integer()}} | {style, integer()} See external documentation . deletePage(This::wxAuiNotebook(), Page::integer()) -> bool() See external documentation . getArtProvider(This::wxAuiNotebook()) -> wxAuiTabArt() (see module wxAuiTabArt) See external documentation . getPage(This::wxAuiNotebook(), Page_idx::integer()) -> wxWindow() (see module wxWindow) See external documentation . getPageBitmap(This::wxAuiNotebook(), Page_idx::integer()) -> wxBitmap() (see module wxBitmap) See external documentation . getPageCount(This::wxAuiNotebook()) -> integer() See external documentation . getPageIndex(This::wxAuiNotebook(), Page_wnd::wxWindow() (see module wxWindow)) -> integer() See external documentation . getPageText(This::wxAuiNotebook(), Page_idx::integer()) -> string() See external documentation . getSelection(This::wxAuiNotebook()) -> integer() See external documentation . insertPage(This::wxAuiNotebook(), Page_idx::integer(), Page::wxWindow() (see module wxWindow), Caption::string()) -> bool() Equivalent to insertPage(This, Page_idx, Page, Caption, []) . insertPage(This::wxAuiNotebook(), Page_idx::integer(), Page::wxWindow() (see module wxWindow), Caption::string(), Options::[Option]) -> bool() Types Option = {select, bool()} | {bitmap, wxBitmap() (see module wxBitmap)} See external documentation . removePage(This::wxAuiNotebook(), Page::integer()) -> bool() See external documentation . setArtProvider(This::wxAuiNotebook(), Art::wxAuiTabArt() (see module wxAuiTabArt)) -> ok See external documentation . setFont(This::wxAuiNotebook(), Font::wxFont() (see module wxFont)) -> bool() See external documentation . setPageBitmap(This::wxAuiNotebook(), Page::integer(), Bitmap::wxBitmap() (see module wxBitmap)) -> bool() See external documentation . setPageText(This::wxAuiNotebook(), Page::integer(), Text::string()) -> bool() See external documentation . setSelection(This::wxAuiNotebook(), New_page::integer()) -> integer() See external documentation . setTabCtrlHeight(This::wxAuiNotebook(), Height::integer()) -> ok See external documentation . setUniformBitmapSize(This::wxAuiNotebook(), Size::{W::integer(), H::integer()}) -> ok See external documentation . destroy(This::wxAuiNotebook()) -> ok Destroys this object, do not use object again AUTHORS
<> wxErlang 0.98.9 wxAuiNotebook(3erl)
All times are GMT -4. The time now is 01:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy