Hoa
Hoa

Reputation: 20448

How can I get awk to print without white space?

When I run the following

awk -F\, '{print $2,":",$1}'

It prints

"First : Second"

How can I get

"First:Second"

Upvotes: 54

Views: 49631

Answers (3)

Ruman
Ruman

Reputation: 1044

 awk '{printf "%s:%s",$2,$1}'

You can also use printf instead of print to get more control over printing things.

Upvotes: 3

je4d
je4d

Reputation: 7848

Omit the ,s

awk -F\, '{print $2 ":" $1}'

Upvotes: 88

ldav1s
ldav1s

Reputation: 16315

Try this:

awk -F\, '{print $2":"$1}'

Upvotes: 8

Related Questions