The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
newline character trichyselva UNIX for Dummies Questions & Answers 9 10-31-2008 01:47 PM
delete newline character between html tags girish312 UNIX for Dummies Questions & Answers 8 02-29-2008 05:24 AM
Substituting carriage return followed by newline character - HELP djkane Shell Programming and Scripting 14 02-28-2006 09:58 PM
Substituting carriage return follwed by newline character - HELP! djkane UNIX for Dummies Questions & Answers 1 02-27-2006 09:11 PM
How can I replace newline character? ghoti UNIX for Dummies Questions & Answers 1 08-16-2001 12:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-22-2005
sanikv sanikv is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 5
Newline character not working for ksh

Newline character "\n" not working for ksh in linux AS 3.0

Command :

$echo "Hi\nHi"
$Hi\nHi
$

Expected output :
$echo "Hi\nHi"
Hi
Hi
$

Can some help me on this

Thanks in advance
Sanish.
  #2 (permalink)  
Old 06-22-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
either:
/bin/echo '"Hi\nHi"

or [if in bash]:
echo -e "Hi\nHi"
  #3 (permalink)  
Old 06-22-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Or you could always use printf....

printf "Hi\nHi\n"

Note - with printf you'll need a trailing newline too

Cheers
ZB
  #4 (permalink)  
Old 06-23-2005
sanikv sanikv is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 5
Hi vgersh99 & zazzybob ,

Thanks for the suggestions.

printf helps to resolve the issue in ksh.

But i have issues with other commands also, so i suspect that there is something to do with the shell i.e setting some environment variables or something.

My main issue is with sed

I am expecting the following output from the follwing command

$ sed -e 's/String1/String0\nString1\nString2/' < aa
String0
String1
String2

But i am getting the following output

$ sed -e 's/String1/String0\nString1\nString2/' < aa
String0nString1nString2

Can you please help me on this
  #5 (permalink)  
Old 06-23-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
sed -e "s/String1/String0`/bin/echo`String1`/bin/echo`String2/" < aa
  #6 (permalink)  
Old 06-23-2005
sanikv sanikv is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 5
Hi vgersh99,

thanks for your response, but it did'nt help

$ cat aa
String1

$ cat x
#!/bin/ksh
sed -e "s/String1/String0`/bin/echo`String1`/bin/echo`String2/" < aa

$ ./x
String0String1String2

Seems that it is ignoring the newline

Thanks,
Sanish
Closed Thread

Bookmarks

Tags
linux

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 06:50 PM.


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