LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices

Reply
 
Search this Thread
Old 11-28-2009, 03:01 AM   #1
sundar_r05
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Lightbulb 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
 
Old 11-28-2009, 03:28 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
You could enter the value as '\svlipc32\masters\xxxx' (with the quotes)
 
Old 11-28-2009, 04:06 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
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.
Old 11-28-2009, 04:48 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by ghostdog74 View Post
use -r

Code:
$ read -r s
That's so much better than my suggestion
 
Old 02-02-2010, 05:01 AM   #5
sundar_r05
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
Old 02-02-2010, 05:23 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Works for me:
Code:
c:~$ read -r val
a\\b
c:~$ echo $val
a\\b
 
Old 02-02-2010, 05:29 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.....)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"failed to execute child process" "Input/output error" fl.bratu Fedora 4 12-15-2008 04:03 AM
fdisk reports odd "Start "and "End" sectors on single partition eponymous Linux - Software 3 10-01-2007 03:41 PM
Repeated "input: AT Translated Set 2 keyboard as /class/input/input" messages AcerKev Mandriva 2 09-16-2007 08:35 AM
"INIT: Going Single User" during boot vwagheim Mandriva 13 11-18-2005 08:38 AM
PHP doesn't "remember" the user input. What to do? linuxfond Programming 10 09-04-2003 07:11 AM


All times are GMT -5. The time now is 10:52 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration