LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-03-2011, 03:58 AM   #1
balakodoth
Member
 
Registered: Dec 2010
Posts: 40

Rep: Reputation: 0
equivalent of read -r


what is the equivalent of read -r (solaris command ) in Linux ?

read utility in solaris will read a single line from standard input and -r option is used not to treat backslash (\) as an escape character .
 
Old 01-03-2011, 04:18 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
All the same as far as I know??
Code:
# help read | grep '\-r'
-r		do not allow backslashes to escape any characters
 
Old 01-03-2011, 04:26 AM   #3
balakodoth
Member
 
Registered: Dec 2010
Posts: 40

Original Poster
Rep: Reputation: 0
thanks grail ,

I like to know whether there is any similar command in linux which does the same functionality as read -r in solaris .
 
Old 01-03-2011, 04:58 AM   #4
balakodoth
Member
 
Registered: Dec 2010
Posts: 40

Original Poster
Rep: Reputation: 0
echo "A B C" | read x y z
echo $x $y $z

gives A B C in solaris but when i give same in Linux it gives blank.

does anyone know how to acheive this in Linux ? ( reading from standard input )
 
Old 01-03-2011, 05:09 AM   #5
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,608

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
Quote:
Originally Posted by balakodoth View Post
echo "A B C" | read x y z
echo $x $y $z

gives A B C in solaris but when i give same in Linux it gives blank.

does anyone know how to acheive this in Linux ? ( reading from standard input )
The problem is that the pipe is being executed in a subshell. 'x', 'y' and 'z' get "A", "B" and "C" assigned. However, after the commands are executed the subshell also exits and the assigned values are lost.

If you want to keep them you can do something like this:
Code:
$ read x y z < <(echo "D E F")
$ echo $x
D
$ echo $y
E
$ echo $z
F
$ echo $x $y $z
D E F
$
 
1 members found this post helpful.
  


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
Program to read total read/write cycles for compact flash card timetraveler Linux - Hardware 0 05-06-2010 10:49 PM
silo read error on block <number>... results in a short read peterlowrie Linux - Hardware 0 02-07-2010 08:39 PM
Raid disk problem : Attempt to read block from filesystem resulted in short read ElmPie Linux - General 5 08-26-2008 06:21 AM
kernel panic unable to mount root (yes ive read/read other posts) dmx9595 Linux - General 4 01-17-2004 06:07 AM


All times are GMT -5. The time now is 06:22 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration