Printing single quotes with awk
Hi,
I have the following command, which works fine: ll /backup/PROD |grep PROD_ |awk -F" " '{print "catalog backuppiece /backup/PROD/"$9";"}' The output is: catalog backuppiece /backup/PROD/PROD_29mi42vn_1_1; BUT... I want single quotes in the result. One before /back.. and one before the ; Like this: catalog backuppiece '/backup/PROD/PROD_29mi42vn_1_1'; How do I do that? I tried using \' but it does not work. The following command works, but I get an error message, which prevents me from using the command in a bash file: ll /backup/PROD |grep PROD_ |awk -F" " '{print "catalog backuppiece \'\''/backup/PROD/"$9"\'\'';"}' awk: warning: escape sequence `\'' treated as plain `'' Regards, Casper |
Hi,
I found a solution to this question - No need for any replies then. I used awk -v ls -l /backup/PROD |grep PROD_ |awk -F" " -v xx="'" '{print "catalog backuppiece " xx "/backup/PROD/"$9 xx";"}' Output is: catalog backuppiece '/backup/PROD/PROD_29mi42vn_1_1'; Regards, Casper |
There is a much better way:
Code:
awk 'BEGIN { print "This is a single qoute: '\'' And this is, too: '"'"'" }' |
Or an even better idea:
Code:
awk '{print "catalog backuppiece \047"FILENAME"\047;";nextfile}' /backup/PROD/*PROD_* |
All times are GMT -5. The time now is 06:28 PM. |