The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
deleting newline characters but not the "true" \n character caddyjoe77 Shell Programming and Scripting 1 08-15-2007 11:21 PM
remove trailing newline characters shweta_d Shell Programming and Scripting 7 06-05-2007 10:29 AM
Formatting a text file based on newline and delimiter characters ntekupal Shell Programming and Scripting 5 05-11-2007 04:33 PM
echo command result umen UNIX for Dummies Questions & Answers 2 11-10-2005 08:39 AM
FTP command result nymus7 IP Networking 1 08-08-2005 06:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-02-2008
pankai pankai is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 14
how to keep newline characters in command execution result?

I found that when I used a variable to receive the result from a command execution, the newline characters were removed from the variable.

For example, I ran

$ ret=`ls -l`
$ echo $ret

Then, I saw:
total 40 -rw-r--r-- 1 testtrunk testtrunk 0 Dec 13 11:13 pk -rw-rw-r-- 1 testtrunk testtrunk 0 Dec 13 11:13 pk1

But the output I expected is:
total 40
-rw-r--r-- 1 testtrunk testtrunk 0 Dec 13 11:13 pk
-rw-rw-r-- 1 testtrunk testtrunk 0 Dec 13 11:13 pk1

So, the question is, how to keep the newline characters in the variable that receives the command result?

Thanks.
  #2 (permalink)  
Old 01-02-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 717
Hi.

Use double-quotes around the variable in the echo ... cheers, drl
  #3 (permalink)  
Old 01-02-2008
pankai pankai is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 14
Quote:
Originally Posted by drl View Post
Hi.

Use double-quotes around the variable in the echo ... cheers, drl
drl, thanks!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0