Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" 
like image 433
Hoa Avatar asked Apr 02 '12 23:04

Hoa


People also ask

How do I change the separator in awk?

Just put your desired field separator with the -F option in the AWK command and the column number you want to print segregated as per your mentioned field separator.

What is awk '{ print $3 }'?

txt. If you notice awk 'print $1' prints first word of each line. If you use $3, it will print 3rd word of each line.

What is awk '{ print $2 }'?

awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output. xargs kill -${2:-'TERM'} takes the process IDs from the selected sidekiq processes and feeds them as arguments to a kill command.


2 Answers

Omit the ,s

awk -F\, '{print $2 ":" $1}' 
like image 112
je4d Avatar answered Sep 20 '22 08:09

je4d


Try this:

awk -F\, '{print $2":"$1}' 
like image 20
ldav1s Avatar answered Sep 17 '22 08:09

ldav1s