|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to print backslash in shell script using awk?
I found that Code:
echo "aaa" | awk '{print ",\\";}'works, and it will give "\". but Code:
ddd=`echo "aaa" | awk '{print ",\\";}'`; echo $dddwill not work. Could anyone tell me why? thank you. Last edited by Scrutinizer; 01-30-2013 at 03:15 PM.. Reason: code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
ddd=$( echo "aaa" | awk '{print ",\\";}' )
echo $ddd |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
it works, Thank you.
|
|
#4
|
||||
|
||||
|
You can use
BEGIN to make
awk work without no input Code:
ddd=$(awk 'BEGIN {print ",\\";}' ) |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Code:
$ ddd=",\\"; echo $ddd ,\ UUOA? |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
ddd=,\\ UUOQ&A
|
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
OP never gave a complete picture of what he was trying to achieve. Thread title is just: "How to print backslash in shell script using awk?"
So I'm not sure if it was UUOQ & UUOA |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing backslash character to awk variable | Mudshark | Shell Programming and Scripting | 5 | 11-18-2012 11:38 AM |
| awk/shell script to print each line to a file | saint2006 | Shell Programming and Scripting | 3 | 01-06-2010 10:26 AM |
| shell script(Preferably awk or sed) to print selected number of columns from each row | ks_reddy | Shell Programming and Scripting | 3 | 08-25-2009 07:39 AM |
| Sed and awk backslash characters | potro | Shell Programming and Scripting | 7 | 05-19-2008 08:34 AM |
| Shell Script -- problem reading backslash(\)!! | rossi143 | Shell Programming and Scripting | 2 | 04-04-2007 02:52 AM |
|
|