Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
11-28-2009, 03:01 AM
#1
LQ Newbie
Registered: Nov 2009
Posts: 2
Rep:
Accepting single backslash "\" as a user input.
Dear friends,
how to do this in shell scripts. any solution for this or no solution.
My input will be : \svlipc32\masters\xxxx
my output should be : \svlipc32\masters\xxxx but its coming as
svlipc32mastersxxxx
presently iam giving i/p as \\svlipc32\\masters\\xxxx to get this
\svlipc32\masters\xxxx
Read Val
echo " Enter the input string \n"
echo $val
please help me in this.
Regards,
sundar
11-28-2009, 03:28 AM
#2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,959
You could enter the value as '\svlipc32\masters\xxxx' (with the quotes)
11-28-2009, 04:06 AM
#3
Senior Member
Registered: Aug 2006
Posts: 2,695
use -r
Code:
$ read -r s
\svlipc32\masters\xxxx
$ echo $s
\svlipc32\masters\xxxx
$read s #without -r
\svlipc32\masters\xxxx
$ echo $s
svlipc32mastersxxxx
1 members found this post helpful.
11-28-2009, 04:48 AM
#4
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,959
Quote:
Originally Posted by
ghostdog74
That's so much better than my suggestion
02-02-2010, 05:01 AM
#5
LQ Newbie
Registered: Nov 2009
Posts: 2
Original Poster
Rep:
Dear friends,
how to do this in shell scripts. any solution for this or no solution.
My input will be : \svlipc32\masters\xxxx ,\\svlipc32\\masters
my output should be : \svlipc32\masters\xxxx,\\svlipc32\\masters but its coming as svlipc32mastersxxxx and \svlipc32\masters
presently iam giving i/p as \\svlipc32\\masters\\xxxx to get this
\svlipc32\masters\xxxx
Read Val
echo " Enter the input string \n"
echo $val
please help me in this.
if I use -r read :
read -r val
echo $val
if i give this as input thats ok :- \svlipc32\masters\xxxx
but if i give this \\svlipc32\\masters as input iam getting \svlipc32\masters not as \\svlipc32\\masters.
Regards,
sundar
02-02-2010, 05:23 AM
#6
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,959
Works for me:
Code:
c:~$ read -r val
a\\b
c:~$ echo $val
a\\b
02-02-2010, 05:29 AM
#7
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: back to Arch
Posts: 16,637
This may be a bit late, but why do you need to have input that includes special characters like this? (Just seems to be asking for trouble.....)
Thread Tools
Search this Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 12:02 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News