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 02:02 AM.. Reason: code tags, please...
# 2  
Old 01-18-2010
Hello,

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

see man 1 echo

Loc.
# 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

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Linux ksh script not working in crontab mrn6430 Red Hat 1 12-16-2015 09:12 PM
ksh on UNIX and Linux rdogadin UNIX for Dummies Questions & Answers 3 10-30-2013 02:09 PM
ksh script migration from Solaris to Linux. Shivdatta Shell Programming and Scripting 6 09-04-2013 05:12 AM
AWK Program Not Executing On Linux with KSH JolietJake Shell Programming and Scripting 5 05-17-2012 04:30 PM
LINUX Cron Schedule - Newline character issue jansat Linux 2 06-14-2011 03:41 PM
clear in Linux ksh pradebban Linux 2 05-26-2011 03:21 PM
Convert special charachter ^C to new line vnag97 Shell Programming and Scripting 2 01-19-2010 11:50 AM
delete line upto the nth occurence of a particular charachter. kashifv Shell Programming and Scripting 12 10-09-2009 07:26 AM
Need to cut filename in LINUX ksh juliyp Shell Programming and Scripting 10 06-09-2009 10:38 AM
sed ksh remove newline between 2 containers JamesJSC Shell Programming and Scripting 3 12-19-2008 04:54 AM
problem escaping newline in ksh JamesByars Shell Programming and Scripting 7 01-05-2008 05:51 PM
ksh/Linux: Variable scoping issue? Pl. help! jasmeet100 Shell Programming and Scripting 2 09-30-2005 07:35 PM
Script Migration From HP to Linux (KSH) Omkumar Shell Programming and Scripting 1 09-02-2005 10:44 AM
Newline character not working for ksh sanikv Shell Programming and Scripting 11 06-23-2005 02:34 PM
Counting occurences of specific charachter in a file GMMike UNIX for Dummies Questions & Answers 3 10-13-2004 03:46 PM
All times are GMT -4. The time now is 04:16 PM.

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





Not a Forum Member?
Forgot Password?