Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting Ś Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Newline charachter in Ksh-Linux

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 01-17-2010
Newline charachter in Ksh-Linux

Hello,

I'm trying to create a muliti value shell variable with newlines inside it, So that I can read the values of that variable individually line by line, but KSH seems to be stripping my variable of newlines in LINUX, but UNIX its working fine.

Here's Example :

Code:
String = "Hello\n""How R U"

echo "$String" |\
   while read _line
   do
     echo $_line
  done

Output in Unix : Hello
Code:
How R U

But In Linux :
Code:
Hello\nHow R U

Please help in solving this.

Thanks!!!!

Last edited by pludi; 01-18-2010 at 01:02 AM.. Reason: code tags, please...
# 2  
Old 01-17-2010
Hello,

Try:
Code:
echo -e "$String" |\
...

see man 1 echo

Lo´c.
# 3  
Old 01-18-2010
Sorry , this is not working !!!
# 4  
Old 01-18-2010
Try:
Code:
String="Hello\nHow R U"
printf "$String\n" |
while read _line
do
  echo $_line
done

Careful when you assign a value to String: spaces around the =-operator are not allowed..
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Newline in the file freakabhi Shell Programming and Scripting 3 10-09-2014 03:02 PM
Insert a newline in XML mohanalakshmi Shell Programming and Scripting 5 07-05-2013 02:24 PM
echo without newline locoroco Shell Programming and Scripting 6 09-20-2012 04:46 PM
LINUX Cron Schedule - Newline character issue jansat Linux 2 06-14-2011 02:41 PM
sed newline azertyazerty Shell Programming and Scripting 2 11-07-2010 04:10 PM
Convert special charachter ^C to new line vnag97 Shell Programming and Scripting 2 01-19-2010 10:50 AM
delete line upto the nth occurence of a particular charachter. kashifv Shell Programming and Scripting 12 10-09-2009 06:26 AM
how to get newline in a text box suresh_kb211 Web Programming 2 09-14-2009 04:27 AM
newline Gale Gorman Forum Support Area for Unregistered Users & Account Problems 2 05-04-2008 12:23 PM
Counting occurences of specific charachter in a file GMMike UNIX for Dummies Questions & Answers 3 10-13-2004 02:46 PM


All times are GMT -4. The time now is 05:56 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password