Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-02-2009
Registered User
 

Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Issue with New Line character

Hi,

I am reading data from file and storing it in a multiline variable. Every line is seperated with "\n" character.

globalstrval="${globalstrval}""${line}""\n"

If the value of globalstrval is like:
1234
ABCD
EFGH
WXYZ
....

If I do,
YLvar=`echo $globalstrval | grep "ABC"`
then it should return me only one line : ABCD, and it is working fine in AIX.

But when I am porting my script on Linux system, I am getting value back as "1234\nABCD\nEFGH\nWXYZ". How can I get it working on both systems? I am using /bin/su. Is there any thing to do with shell?

Any help is much appreciated.

Thanks,
- Ashish
Sponsored Links
    #2  
Old 12-02-2009
Moderator
 

Join Date: Feb 2007
Location: The Netherlands
Posts: 7,160
Thanks: 53
Thanked 396 Times in 378 Posts
Concatenate the strings like this, assuming you're using bash:


Code:
globalstrval="${globalstrval}" $'\n' "${line}"

Sponsored Links
Closed 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
Awk not working due to missing new line character at last line of file pinnacle Shell Programming and Scripting 2 05-07-2009 10:51 PM
Need to serach if a new line character exists on the last line in a file sunilbm78 UNIX for Dummies Questions & Answers 10 02-29-2008 02:15 PM
character spacing issue wxornot Shell Programming and Scripting 1 03-08-2006 08:22 PM
delete a line based on first character of the line borncrazy UNIX for Dummies Questions & Answers 2 12-06-2005 03:27 PM
Issue with dispaly of special character like 'TM' vbehal UNIX for Advanced & Expert Users 0 11-13-2005 04:15 AM



All times are GMT -4. The time now is 02:14 PM.