Escape sequence | Unix Linux Forums | Shell Programming and Scripting

  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 Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-08-2006
puspendu's Avatar
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 02-08-2006
vino's Avatar
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 9 April 2013, 8:19 AM EDT
Location: Sydney, Down Under
Posts: 2,847
Thanks: 0
Thanked 12 Times in 12 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 02-08-2006
puspendu's Avatar
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 02-08-2006
vino's Avatar
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 9 April 2013, 8:19 AM EDT
Location: Sydney, Down Under
Posts: 2,847
Thanks: 0
Thanked 12 Times in 12 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 02-08-2006
puspendu's Avatar
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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:02 PM
Removing Escape Sequence Characters cutechaps Shell Programming and Scripting 2 04-29-2010 01:18 AM
escape sequence for $ shreekrishnagd Shell Programming and Scripting 5 08-26-2008 10:47 AM
Both HOME and INSERT key send same escape sequence on ssh grossgermany UNIX for Dummies Questions & Answers 0 07-27-2007 08:12 PM
want to view the escape sequence sweta UNIX for Advanced & Expert Users 4 10-09-2006 11:20 AM



All times are GMT -4. The time now is 06:45 AM.