Escape sequence | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Escape sequence

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-07-2006
puspendu's Unix or Linux Image
puspendu puspendu is offline
Registered User
 
Join Date: Jul 2004
Last Activity: 1 September 2011, 2:01 AM EDT
Location: INDIA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Escape sequence

Hi,

I have got an application through which an user will submit an address like "c:\tuser\abc".
This application calls a script and passes the address to the scripts positional parameter say $1.
So $1 should contain "c:\tuser\abc", but when $1 is echoed the "\t" and "\a" are interpreted to escape sequence 'tab' and 'bell'.
I cannot ask the user to enter the address in any other format.
Please let me know how to resolve this issue.

TIA,
Puspendu
Sponsored Links
    #2  
Old Unix and Linux 02-08-2006
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
If you are using echo to print the address back to the user, then try


Code:
echo -E "c:\tuser\abc"

From the man pages of echo


Code:
       -e     enable interpretation of the backslash-escaped characters listed
              below

       -E     disable interpretation of those sequences in STRINGs

Man pages of sh, ksh also mention the usage of echo -E to disable interpretation.
Sponsored Links
    #3  
Old Unix and Linux 02-08-2006
puspendu's Unix or Linux Image
puspendu puspendu is offline
Registered User
 
Join Date: Jul 2004
Last Activity: 1 September 2011, 2:01 AM EDT
Location: INDIA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Data

Hi Vino,

Thnx for the quick reply but as we know the echo command varies a lot across different shell, so is the case here.

I am on 'AIX' and 'ksh' shell.

So the -e/-E options are not supported, I also confirmed from the man pages for echo.

Regards,
Puspendu
    #4  
Old Unix and Linux 02-08-2006
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
Since you are using ksh as the shell, try

print -r "c:\tuser\abc"

I am not very sure about the following command. But try.

printf "%s\n" "c:\tuser\abc"
Sponsored Links
    #5  
Old Unix and Linux 02-08-2006
puspendu's Unix or Linux Image
puspendu puspendu is offline
Registered User
 
Join Date: Jul 2004
Last Activity: 1 September 2011, 2:01 AM EDT
Location: INDIA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Bug

Thanks Vino
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with escape sequence for '$' symbol in EGREP function xylus77 Shell Programming and Scripting 3 03-14-2012 04:02 PM
Removing Escape Sequence Characters cutechaps Shell Programming and Scripting 2 04-29-2010 12:18 AM
escape sequence for $ shreekrishnagd Shell Programming and Scripting 5 08-26-2008 09:47 AM
Both HOME and INSERT key send same escape sequence on ssh grossgermany UNIX for Dummies Questions & Answers 0 07-27-2007 07:12 PM
want to view the escape sequence sweta UNIX for Advanced & Expert Users 4 10-09-2006 10:20 AM



All times are GMT -4. The time now is 12:06 PM.