Put words to fix position in a file

Hi all,

There are several lines in my file as

a=123,b=dene,c=2312,d=234234,g=vxcvxcv,h=44
a=3,b=dene,c=22,d=23422342334,g=vxcvxcv,h=4
a=123,b=dene,c=2312,d=234234,g=vxcvxcv,h=678

I take values with this command

awk -F '[=,]' '{print $1,$2,$3}' a.txt

I want to put values to a fix position (starting at same point) of a file as:

123         dene          2312        234234               44
3            dene          22            23422342334       4

$1 must start at 0th position of line
$2 must start at 19th position of line
$3 must start at 39th position of line
$4 must start at 50th position of line

Please help me to do this.

Thanks.

I'm confused. You awk program prints 3 values (and not the first three of the five you say are being output) and you give output column positions for 4 values.

Please give us a clear example explaining which fields you want selected from your sample input lines and show us what the output should actually look like. Please use code tags when you post your input file contents, code segments, and expected output examples.

Is this what you are trying to achieve:-

awk -F '[=,]' '{printf "%-3s%19s%20s%18s\n", $2, $4, $6, $8}' a.txt
123               dene                2312            234234
3                 dene                  22       23422342334
123               dene                2312            234234

Just as an fyi there is a great tool(csvfix - CSVfix is a tool for manipulating CSV data - Google Project Hosting) for dealing with csv, fixed format, etc.
For example, You could probably use a 'template' to accomplish what you want.

As Don Cragun says, you leave us to wild guessing. Nevertheless, bipinajith's proposal might do what you want if slightly adapted:

awk -F'[=,]' '{printf "%-18s%-20s%-11s%-11s%-11s\n", $2,$4,$6,$8,$10}' file
123               dene                2312       234234     vxcvxcv    
3                 dene                22         23422342334vxcvxcv    
123               dene                2312       234234     vxcvxcv

After seeing bipinajith's proposal, I had considered this too. Note that in the 1st posting, the last output field comes from $12, not $10. I had come up with:

awk -F "[=,]" '{printf("%-19s%-20s%-11s%-20s%s\n",$2,$4,$6,$8,$12)}' file

which produces:

123                dene                2312       234234              44
3                  dene                22         23422342334         4
123                dene                2312       234234              678

but was waiting for bahadiraktan to respond to determine what value should be used instead of the 20 I have shown in red above. I had 19 for the first field's width instead of the 18 you used because bahadiraktan was specifying the 1st output column as #0 instead of the usual #1.

Good point - the #0 should have triggered my attention as well - but the entire request was, say, a bit inconsistent.