user3823859
user3823859

Reputation: 469

Enclose within double quotes

I have command like this, but I need each output line to be enclosed within double quotes ("..."). How to modify this command?

awk '{ for (i = 2; i <= NF; i++) { printf("%s ", $i); } printf("\n") }' all.txt > result.txt

Upvotes: 1

Views: 161

Answers (1)

Yu Hao
Yu Hao

Reputation: 122383

printf("\"") prints out a double quote, Add it before and after the loop:

awk '{ printf("\""); for (i = 2; i <= NF; i++) { printf("%s ", $i); } printf("\"\n") }' t.txt

Upvotes: 2

Related Questions