how to print backslah using echo


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to print backslah using echo
# 1  
Old 04-12-2007
how to print backslah using echo

how to print 3 backslah using Unix AIX,
i have try in my fedora and AIX,both give dirrent output for same echo statment
test.sh
Code:
sed -e 's/\(["`]\)/\\\1/g' -e 's/\$?/\\$?/g' -e 's/\$#/\\$#/g' -e 's/^/echo "/g' -e 's/$/ "/g' xMNBDF070 > xMNBDF070_test

xMNBDF070
Code:
sed -e "s/'/\\\'/g" -e 's/\([();*|>]\)/\\\1/g' $SCRIPTSQL/xMNBDF070_Script.sql > $TEMP_PATH/xMNBDF070_Script.sql.TMP

letsay,
SCRIPTSQL=/home/mani
TEMP_PATH=/home/mani/temp

sh xMNBDF070_test
output
Code:
sed -e "s/'/\\\'/g" -e 's/\([();*|>]\)/\\\1/g' /home/mani/xMNBDF070_Script.sql > /home/mani/temp/xMNBDF070_Script.sql.TMP

how to alter test.sh to print above line in xMNBDF070
because i get this
Code:
sed -e "s/'/\'/g" -e 's/\([();*|>]\)/\1/g' /home/mani/xMNBDF070_Script.sql > /home/mani/temp/xMNBDF070_Script.sql.TMP

i dunno how many backslah to use because in Unix to get 3 backslah i echo like this
echo "\\\\\\\\\ "

but in linux i use pair backslah
echo "\\\\\\ "

why its diffrent and how to know how many backslach needed
please guide
# 2  
Old 04-12-2007
Code:
$ echo '\\\\\\'
\\\

# 3  
Old 04-12-2007
Quote:
Originally Posted by anbu23
Code:
$ echo '\\\\\\'
\\\


Anbu,

Do we need to use 6 back slashes if enclose it in single quotes?
echo '\\\'
should give the desired o/p.
Or we have to use echo "\\\\\\"
# 4  
Old 04-12-2007
Quote:
Originally Posted by jacoden
Anbu,

Do we need to use 6 back slashes if enclose it in single quotes?
echo '\\\'
should give the desired o/p.
Or we have to use echo "\\\\\\"
\\ is taken as single slash even if you enclose it in single quotes.This is taken as escape sequence and give single slash
# 5  
Old 04-12-2007
ok thanks i get it now..
in unix its like this

echo '\\\\'
output
\\
echo "\\\\"
output
\

thanks
i get it from man echo
# 6  
Old 04-12-2007
Anbu...
Bit confusing for me...
See this
Code:
u142115@linux2alm:~/new> echo $SHELL
/bin/bash
u142115@linux2alm:~/new> echo '\\\'
\\\
u142115@linux2alm:~/new> echo "\\\\\\"
\\\
u142115@linux2alm:~/new> echo '\\\\\\'
\\\\\\

# 7  
Old 04-12-2007
Code:
[af]: /nf01
=> echo $SHELL
/usr/bin/ksh
[af]: /nf01
=> echo '\\\'
\\
[af]: /nf01
=> echo "\\\\\\"                                          
\\
[af]: /nf01
=> echo '\\\\\\'
\\\

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Echo print on same line while loop using variable

Currently using below script but echo it print the output in two line. Input file all-vm-final-2.txt CEALA08893 SDDC_SCUN DS_SIO_Workload_SAPUI_UAT_01 4 CEALA09546 SDDC_SCUN DS-SIO-PD5_Workload_UAT_SP1_Flash_07 4 CEALA09702 SDDC_SCUN DS-VSAN-RMP-WORKLOAD01 4 DEALA08762 SDDC_LDC... (3 Replies)
Discussion started by: ranjancom2000
3 Replies

2. Shell Programming and Scripting

Replacing echo with print

Hi everyone, I'm executing a shell script and one of the commands is creating a file with text via echo. However, if the text within echo has "\t" or similar, it automatically translates it into a TAB character, same goes for other special characters. I know that if I put another "\"... (7 Replies)
Discussion started by: demmel
7 Replies

3. Shell Programming and Scripting

Using echo to print arguments inside a function

I am using echo in bash. Have created a function prargv which takes a number of arguments. Example: prargv "-e" "--examples" Inside prargv, I want to print all the arguments using echo echo "$@" This returns --examples rather than -e --examples" This problem can be fixed... (3 Replies)
Discussion started by: kristinu
3 Replies

4. Shell Programming and Scripting

Print (echo) variable in a single line

Hi, I have written this code ------------------------------------------------ # !/bin/ksh i=0 while do j=$i while do echo -e $j #printf "%d",$j j=`expr $j - 1` done echo i=`expr $i + 1` done ---------------------------------------------------- The ouput which... (2 Replies)
Discussion started by: rac
2 Replies

5. Shell Programming and Scripting

Echo print in different lines within email sent by Cron job

Hi all, I think this could have a simple solution, just I canīt get it so far. I have the script below that includes several echo commands in order to show that every part of the script have been executed. A cron job executes this script and when is completed the output is sent by email. ... (4 Replies)
Discussion started by: cgkmal
4 Replies

6. Shell Programming and Scripting

echo/print variable question

while read filer ; do echo $filer $1 $2; ssh $filer vfiler status -r | awk '/running/{host=$1}/Path:/{path=$2;print host,path}'; done < filers.list this will print node1 vfiler0 / vfiler2 /vol/vfiler2_vol0 vfilert /vol/vfiler_vol vfilert /vol/virt_vol where node1 = $filer. however how... (1 Reply)
Discussion started by: riegersteve
1 Replies

7. Shell Programming and Scripting

Using echo to print double quotes along with variable substitution

Hi, I am generating html code using cshell, but i am having one problem while printing double quotes, I need to write following code in file. where $var contains list of web address <a href="$var">$var</a> So i am using echo "<a href="$var">$var</a>" > file.html But with this " in... (4 Replies)
Discussion started by: sarbjit
4 Replies

8. Shell Programming and Scripting

Differenc between print and echo

can anyone explain me what is the difference between echo and print in shell programming? (3 Replies)
Discussion started by: chandhar
3 Replies

9. UNIX for Dummies Questions & Answers

echo vs. print

Is there a functional difference between echo and print? (1 Reply)
Discussion started by: PhilW
1 Replies

10. UNIX for Dummies Questions & Answers

echo or print to screen and file

I did a search for this topic but I couldn't find it and I was sure I have seen something similar before (hard because I am not sure of the criteria for the keywords) What I was looking for was to be able to echo a message to the screen from a bash.sh script at the same time logging it to a... (2 Replies)
Discussion started by: Shakey21
2 Replies
Login or Register to Ask a Question