How do I get awk to print a " in it's print part?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I get awk to print a " in it's print part?
# 1  
Old 06-27-2006
How do I get awk to print a " in it's print part?

The line is simple, use "[" as a field separator for the bits. What I need to do is put a " between $2 and $3.

I can't seem to figure out the escape character needed to get awk to actually print out the " and not think it's part of a bigger double ".

Any ideas?

awk -F[ '{ print $1"["$2$3 }' file.txt| awk -F] '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }'

I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ".

Thanks.
LordJezo
# 2  
Old 06-27-2006
I'm not sure this is exactly what you wanted.

cat file | awk -F: '{print $1, $2, "\"", $3}'


sybqad0l 1706 " 546
sybbev0x 6218 " 542
wpati0k 8145 " 253
wembi02 4621 " 267
pimdp01 223 " 133
abainn1 7098 " 1141
abaibm1 7094 " 1141

-X
# 3  
Old 06-27-2006
Try...
Code:
awk '{print $3 "\042" $4}'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why awk print is strange when I set FS = " " instead of FS = "\t"?

Look at the following data file(cou.data) which has four fields separated by tab. Four fields are country name, land area, population, continent where it belongs. As for country name or continent name which has two words, two words are separated by space. (Data are not accurately... (1 Reply)
Discussion started by: chihuyu
1 Replies

2. Shell Programming and Scripting

Cmd="grep 'Name:' |awk -F' ' '{print $2}'"

Hi Is it possible to get the below code working.? cmd="grep 'Name:' |awk -F' ' '{print $2}'|xargs -i basename {}" echo $cmd ( rman target / <<EOF1 LIST COPY ; exit EOF1 ) | `$cmd` in nutshell I want to be able to preset cmd as depending on script flow it can be... (2 Replies)
Discussion started by: zam
2 Replies

3. UNIX for Dummies Questions & Answers

use cut or awk to print line after "/bin"

Hello all, i am trying to use cut or awk to make my below lines to From $ ps -ef|grep tns|grep -v grep |grep LISTENER_TEST|awk '{print $9}' /oracle/ORAHOME/test/112/bin/tnslsnr to /oracle/ORAHOME/test/112 how can this be achieved ? so basically anything before "/bin" (3 Replies)
Discussion started by: abdul.irfan2
3 Replies

4. Shell Programming and Scripting

awk based script to print the "mode(statistics term)" for each column in a data file

Hi All, Thanks all for the continued support so far. Today, I need to find the most occurring string/number(also called mode in statistics terminology) for each column in a data file (.csv type). For one column of data(1.txt) like below Sample 1 2 2 3 4 1 1 1 2 I can find the mode... (6 Replies)
Discussion started by: ks_reddy
6 Replies

5. Shell Programming and Scripting

Variable interpolation in "print" of awk command

Hi, I have a snippet like below. Based on variable i, i wish to print 1,2,3,4,5th columns to Sample files. For each loop, one column from contetn and results will be pused to sample files. But i have a problem here i=1 while ; do `awk -F"\t" '{print $($i)}' $content > Sample_${i}_original`;... (4 Replies)
Discussion started by: forums123456
4 Replies

6. Shell Programming and Scripting

Awk find in columns with "if then" statement and print results

I have a file1.txt file1.txt F-120009210","Felix","U-M-F-F-F-","white","yes","no","U-M-F-F-F-","Bristol","RI","true" F-120009213","Fluffy","U-F-","white","yes","no","M-F-","Warwick","RI","true" U-120009217","Lity","U-M-","grey","yes","yes","","Fall River","MA","true"... (4 Replies)
Discussion started by: charles33
4 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. Shell Programming and Scripting

grep '\~' b | awk '{print $1","$3}' | sed -e 's/~//g'

Hi all, grep '\~' b | awk '{print $1","$3}' | sed -e 's/~//g' Iam using above command for some report... can this be done using any one of them either sed or awk or grep... (3 Replies)
Discussion started by: harshakusam
3 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question