LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-30-2010, 01:19 PM   #1
timbCFCA
LQ Newbie
 
Registered: Oct 2009
Posts: 10

Rep: Reputation: 0
Subshell multiline output


I'm putting together a small bash script which uses diff in a sub shell.
RESULT=$(diff file1 file2)

This is the first time I've tried to return multiline output from a subshell - how can I get this to display as multiple lines instead of one?
 
Old 08-30-2010, 01:23 PM   #2
timbCFCA
LQ Newbie
 
Registered: Oct 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Also, looping breaks at every word not every line.

Last edited by timbCFCA; 08-30-2010 at 01:26 PM.
 
Old 08-31-2010, 01:30 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,349

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
Re Q2: be nice to see an example, but I think you need the IFS variable http://tldp.org/LDP/Bash-Beginners-G...ml#table_03_01 & 11.7 here http://tldp.org/LDP/abs/html/loops1.html
 
1 members found this post helpful.
Old 08-31-2010, 07:34 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The assignment shown does put multiple lines in $RESULT. How are you displaying the value of $RESULT?
Code:
c@CW9:~/d$ result=$(diff /tmp/trash[12])
c@CW9:~/d$ echo "$result"
2,3c2,3
< def
< ghi
---
> deF
> ghI
c@CW9:~/d$ echo $result
2,3c2,3 < def < ghi --- > deF > ghI
 
1 members found this post helpful.
Old 09-01-2010, 08:46 AM   #5
timbCFCA
LQ Newbie
 
Registered: Oct 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks gentlemen. The quoting on the echo fixed my issue.
I would have sworn I already tried that but I guess not. Thanks for being an extra set of eyes.
 
  


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
exit from subshell ravibhure Linux - Newbie 2 04-21-2010 02:08 AM
does the `( )' create a subshell? tianlijian Linux - Newbie 1 04-19-2009 07:39 AM
Help, with subshell I think? :S DjRakso Linux - Newbie 3 10-28-2007 03:24 PM
mc subshell.c: read (subshell_pty...): rickenbacherus Linux - Software 2 07-14-2004 07:14 PM
Continuing a script on a new subshell dpillay Programming 2 05-29-2004 07:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:36 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
Open Source Consulting | Domain Registration