Parsing multipe data entries


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing multipe data entries
# 1  
Old 05-18-2011
Parsing multipe data entries

Hi

I am using command
Code:
awk '{printf $1 " "}' PMT_GGSN_WPP_APN-20110517* > outfile

The * refers to 24 files (1 generated per hour per day) with each one having the output of
Code:
A1       
A2       
A3       
A4       
A5       
A6       
A7       
A8       
A9       
A10

I need to organise the data into colums so that the outfile looks something like
Code:
A1   B1   C1   D1
A2   B2   C2   D2
A3   B3   C3   D3
A4   B4   C4   D4
A5   B5   C5   D5
A6   B6   C6   D6
A7   B7   C7   D7
A8   B8   C8   D8
A9   B9   C9   D9
A10   B10   C10   D10

How can I amend my awk comand to do so?
# 2  
Old 05-18-2011
Do all of your 24 files have the same number of lines ?

you want your final output file having 4 columns or having 24 columns ?
# 3  
Old 05-18-2011
Every file has 39 entries.
Every day 24 files are produced, 1 for every hour
So my outfile should have 24 lines X 39 columns
Does that make sense?
# 4  
Old 05-18-2011
Oooops sorry it is not clear

The following :

Code:
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10

is the output of 1 file ???
or is it the {print $1} of 10 files ?

Is your problem to set the entries of a file into 1 line ?

...or is it to concatenate columns from different files (what the "paste" command actually does)

Last edited by ctsgnb; 05-18-2011 at 07:24 AM..
# 5  
Old 05-18-2011
If I could attach the desired output via excel here it would help. Is that possible?
(sory ctsgnb but your lat piost did not work)
Code:
awk '{print $1}' PMT_GGSN_WPP_APN-20110517* | xargs -n4 
awk '{print $1}' PMT_GGSN_WPP_APN-20110517* | paste -d"\t" - - - -

---------- Post updated at 05:44 AM ---------- Previous update was at 05:23 AM ----------

Quote:
Originally Posted by ctsgnb
Oooops sorry it is not clear

The following :

Code:
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10

is the output of 1 file ???
or is it the {print $1} of 10 files ?

Is your problem to set the entries of a file into 1 line ?

...or is it to concatenate columns from different files (what the "paste" command actually does)
Quote:
Sry for confusion.
It is the output of 1 file--each file has 39 lines

I need to take each one of those enries on each line and arrange into a column so I end up with 39 columns and 24 lines.. hope this clartifies??
---------- Post updated at 05:49 AM ---------- Previous update was at 05:44 AM ----------

Maybe this make sit clearer. I will base this on a 5 line entry file as opposed to 39 for ease.

each file looks like
Code:
A1
B1
C1
D1
E1

and what I need is to have outfile looking like
Code:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
A4 B4 C4 D4 E4
A5 B5 C5 D5 E5
A6 B6 C6 D6 E6
A7 B7 C7 D7 E7
A8 B8 C8 D8 E8
A9 B9 C9 D9 E9
A10 B10 C10 D10 E10
A11 B11 C11 D11 E11
A12 B12 C12 D12 E12
A13 B13 C13 D13 E13
A14 B14 C14 D14 E14
A15 B15 C15 D15 E15
A16 B16 C16 D16 E16
A17 B17 C17 D17 E17
A18 B18 C18 D18 E18
A19 B19 C19 D19 E19
A20 B20 C20 D20 E20
A21 B21 C21 D21 E21
A22 B22 C22 D22 E22
A23 B23 C23 D23 E23
A24 B24 C24 D24 E24

# 6  
Old 05-18-2011
Code:
paste -sd " " PMT_GGSN_WPP_APN-20110517*

Code:
# ls h*
h1  h2  h3  h4  h5
# cat h1
A1
B1
C1
D1
E1
F1
G1
# cat h2
A2
B2
C2
D2
E2
F2
G2
# paste -sd " " h*
A1 B1 C1 D1 E1 F1 G1
A2 B2 C2 D2 E2 F2 G2
A3 B3 C3 D3 E3 F3 G3
A4 B4 C4 D4 E4 F4 G4
A5 B5 C5 D5 E5 F5 G5

This User Gave Thanks to ctsgnb For This Post:
# 7  
Old 05-18-2011
Many Thanks (again) ctsgnb
Can you explain the xargs ???

---------- Post updated at 06:11 AM ---------- Previous update was at 06:10 AM ----------

and yes I'm all over the man xargs!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

2. Shell Programming and Scripting

Parsing file data

Hey Guys, I'm a novice at shell scripts and i need some help parsing file data. Basically, I want to write a script that retrieves URLs. Here is what I have so far. #!/bin/bash echo "Please enter start date (format: yyyy-mm-dd):\c" read STARTDATE echo "Please enter end date... (7 Replies)
Discussion started by: silverdust
7 Replies

3. Shell Programming and Scripting

Help with parsing data with awk , eliminating unwanted data

Experts , Below is the data: --- Physical volumes --- PV Name /dev/dsk/c1t2d0 VG Name /dev/vg00 PV Status available Allocatable yes VGDA 2 Cur LV 8 PE Size (Mbytes) 8 Total PE 4350 Free PE 2036 Allocated PE 2314 Stale PE 0 IO Timeout (Seconds) default --- Physical volumes ---... (5 Replies)
Discussion started by: rveri
5 Replies

4. Shell Programming and Scripting

Parsing iostat data

Hello, I searched the forum and found the parsing iostat data in real time but that does not help me. What I would like to do is to parse the iostat data that has been gathered. Below is an example of the iostat output: System configuration: lcpu=4 drives=5 ent=0.10 paths=20 vdisks=2 ... (11 Replies)
Discussion started by: tommyd
11 Replies

5. Shell Programming and Scripting

Data parsing

Hi, I do have a data file which is divided into compartments by ---------. I would like to extract (parse) some of the data and numbers either using awk or sed The file has the format: CATGC Best GO enrichment: Genes/ORF that have the motifs (genes are sorted by max(pa+pd+po)): ... (6 Replies)
Discussion started by: Lucky Ali
6 Replies

6. Shell Programming and Scripting

Help in Parsing data

I have below string Transaction_ID:SDP-DM-151204679 , Transaction_DateTime:2011-02-11 00:00:15 GMT+05:30 , Transaction_Mode:WAP , Circle_ID:4 , Circle_Name:BJ ,Zone: , CustomerID:B_31563486 , MSISDN:7870904329 , IMSI:405876122068099 , IMEI: , Sub_Profile:Pre-Paid , CPID:Nazara , CPNAME:Nazara ,... (6 Replies)
Discussion started by: poweroflinux
6 Replies

7. Shell Programming and Scripting

Parsing the data

Hi friends, I need to parse the following data in the given format and get the desired output. I need a function, which takes the input as a parameter and the desired output will be returned from the function. INPUT(single parameter as complete string) A;BCF;DFG;FD ... (3 Replies)
Discussion started by: sumesh.1988
3 Replies

8. Shell Programming and Scripting

Parsing data

Hi all , I have a file with billing CDR records in it. I need to parse that information (row format) . The purpose is to compare full content. The example I have given below is a single line record but it has two portions, (1) the line start with “!” and end with “1.2.1.8” and (2) second part... (5 Replies)
Discussion started by: jaygamini
5 Replies

9. Shell Programming and Scripting

More efficent Data Parsing

I am looking for a way to parse out some numbers from text. This is an excerpt from a larger script that I am trying to make run a little smoother. Specifically this script is used to Capture DV video streams on a linux machine from the terminal. The setup does 6 streams at once, and this part... (3 Replies)
Discussion started by: Starcast
3 Replies

10. Shell Programming and Scripting

Parsing the data

Hi I need to parse the following data using shell script Table ----- stage4n_abc 48 stage4o_abcd 4 adashpg_abc_HeartBeat 1 stage4l_asc 168 Can anyone gimme the solution. I want each value to get stored in an array or variable and want the value to be greped from another file.... (1 Reply)
Discussion started by: Archana.Dheepan
1 Replies
Login or Register to Ask a Question