awk convert from line to column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk convert from line to column
# 1  
Old 08-13-2008
MySQL awk convert from line to column

i have an output like this :
012008
25760883
022008
12273095
032007
10103
032008
10115642
042007
20952798

but i would like to have it like this
012008,25760883
022008,12273095
032007,10103
032008,10115642
042007,20952798


any help will be apreciated
# 2  
Old 08-13-2008
Seems like homework question.
# 3  
Old 08-13-2008
Code:
#  paste -d"," - - < file
012008,25760883
022008,12273095
032007,10103
032008,10115642
042007,20952798

# 4  
Old 08-13-2008
This can do the job:
Code:
awk '{a=$0;getline;printf "%s,%s\n",a,$0}' file

# 5  
Old 08-13-2008
Thanks a lot Danmero .

Mr ynilesh if you have something for it is ok if not keep you mouth shut you'll do a favor to all people.

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert a column to a line

Hi, I need to convert my text file into a sort of matrix form. my input file has 5 columns. $2 and $4 will be ignored and omitted from output, while $3 need to be re-arranged horizontally on top:- Akd1 aa233 Akd1 545 524.2 jlk01 aa233 Akd1 90 447 mht5 ... (2 Replies)
Discussion started by: redse171
2 Replies

2. Shell Programming and Scripting

Convert awk line into perl

I have an awk statement in a ksh script that looks for a certain string then looks at each line after to find another match. The match could be the next line or second down and it works well. nawk 'BEGIN {FS=RS;RS="!"} /interface loopback0/ {for(i=1;i<=NF; i++) if ($i ~ /ip... (5 Replies)
Discussion started by: numele
5 Replies

3. Shell Programming and Scripting

awk or sed - Convert 2 lines to 1 line

Hi, Just trying to get to grips with sed and awk for some reporting for work and I need some assistance: I have a file that lists policy names on the first line and then on the second line whether the policy is active or not. Policy Name: Policy1 Active: yes Policy... (8 Replies)
Discussion started by: guinch
8 Replies

4. UNIX for Dummies Questions & Answers

awk: convert column to row in a specific way

Hi all! I have this kind of output: a1|b1|c1|d1|e1 a2|b2|c2 a3|b3|c3|d3 I would like to transpose columns d and e (when they exist) in column c, and under the row where they come from. Then copying the beginning of the row. In order to obtain: a1|b1|c1 a1|b1|d1 a1|b1|e1 a2|b2|c2... (1 Reply)
Discussion started by: lucasvs
1 Replies

5. Shell Programming and Scripting

Awk next line as column

Hi, This forum rocks. I think this might be an easy thing, but since I am new to awk, please help me. input: x y z 1 a b c 2 d e f 3 g h i 7 output: x y z 1 a b c 2 d e f 3 (8 Replies)
Discussion started by: jacobs.smith
8 Replies

6. Shell Programming and Scripting

Counting rows line by line from a specific column using Awk

Dear UNIX community, I would like to to count characters from a specific row and have them displayed line-by-line. I have a file called testAwk2.csv which contain the following data: rabbit penguin goat giraffe emu ostrich I would like to count in the middle row individually... (4 Replies)
Discussion started by: vnayak
4 Replies

7. Shell Programming and Scripting

How to convert irregular lines into formatted column using awk in windows2003 server environment?

Dear experts, I'm newbie to awk scripting. Need your great help to convert the irregular lines into column using awk in windows2003 server environment. (Sorting based on "Pri Number" column) Input files is as follows: Partition Name: OA Partition UID: ... (0 Replies)
Discussion started by: ruirus
0 Replies

8. UNIX for Dummies Questions & Answers

Convert first line into column

I have a file: 2009_11 3455 500 5355 600 7777 700 The first line is the period. I want to concatenate the Period into every line using a one line command..I guess maybe awk or something. So the output would look like this: 3455 500 2009_11 5355 600 2009_11 7777 700 2009_11 ... (4 Replies)
Discussion started by: alfredo123
4 Replies

9. Shell Programming and Scripting

line to column using awk

hi, i'm a newbie and this is my first post here. 'hope all of you fellow members are doing fine. so here is my first thread to ask for help on how to use awk language to do this task. i have a file to process and after a series of other awk commands and shell scripts i managed to convert the... (11 Replies)
Discussion started by: genix2008
11 Replies

10. UNIX for Dummies Questions & Answers

read a line from a csv file and convert a column to all caps

Hello experts, I am trying to read a line from a csv file that contains '.doc' and print the second column in all caps. e.g. My csv file contains: Test.doc|This is a Test|test1|tes,t2|test-3 Test2.pdf|This is a Second Test| test1|tes,t2|t-est3 while read line do echo "$line" |... (3 Replies)
Discussion started by: orahi001
3 Replies
Login or Register to Ask a Question