newline in echo | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Unix/Linux Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

newline in echo

UNIX for Dummies Questions & Answers


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-19-2010
rikyer rikyer is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 20 January 2010, 5:52 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
newline in echo

Hi all,
I have a scripts in csh and whenI do echo command I want to add newline.
I used to do it like this:

Code:
#! /bin/csh
echo "\n\n WHAT AREA DO YOU WANT:\n\n"
echo -n "     YOUR CHOISE : "
set area=$<

but since weupgrade the oracle to 10g it doesn't do the newline (he print the\n as a text).
I try to do echo -e but the same problem (he also print the -e).
the echo -e only work is sh command but not un csh witch I need in order for his to know the echo -n....
I allso try adding enter in the echo but I got error.

do you know how can I do it?

Last edited by Scott; 01-19-2010 at 08:10 AM.. Reason: Please use code tags
Sponsored Links
    #2  
Old Unix and Linux 01-19-2010
fpmurphy's Unix or Linux Image
fpmurphy fpmurphy is offline Forum Staff  
who?
 
Join Date: Dec 2003
Last Activity: 4 March 2015, 7:58 AM EST
Location: /dev/ph
Posts: 4,890
Thanks: 68
Thanked 445 Times in 413 Posts
Try using /bin/echo when you want to process escape characters such as \n.
Sponsored Links
    #3  
Old Unix and Linux 01-19-2010
methyl methyl is offline Forum Advisor  
Advisor
 
Join Date: Mar 2008
Last Activity: 12 February 2015, 7:41 PM EST
Posts: 6,397
Thanks: 288
Thanked 674 Times in 643 Posts
Try this:


Code:
#!/bin/csh
echo ""
echo ""
echo "WHAT AREA DO YOU WANT:"
echo ""
echo ""
echo "     YOUR CHOISE : \c"
set area=$<


Failing that, please state your Operating System.

Last edited by methyl; 01-19-2010 at 09:54 AM.. Reason: Removed space from shebang line
    #4  
Old Unix and Linux 01-20-2010
rikyer rikyer is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 20 January 2010, 5:52 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

I dont want to do echo "" for each enter because this is a long script and it will be even longer.
our system change to RHEL.
from some serch I saw thet there may by an envairment that I need to add to the script but I dont know what (still looking)
if you have some idea or other ideas I will be happy to try it.
Sponsored Links
    #5  
Old Unix and Linux 01-20-2010
xoops xoops is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 29 March 2012, 3:19 AM EDT
Posts: 124
Thanks: 0
Thanked 7 Times in 7 Posts
you can write a function which will print the output in desired format and then you can call this function instead of echo.
something like..

Code:
 
function echo2()
{
echo ""
echo "$1"
echo ""
}
 
echo2 "print this"

please ignore the syntax error, not sure if its correct.
Sponsored Links
    #6  
Old Unix and Linux 01-20-2010
rikyer rikyer is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 20 January 2010, 5:52 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
not so practical

I have some menu and it goes from one to one (depent of the user choise) so I will have to get lt of functions...
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to correctly use an echo inside an echo? mokachoka UNIX for Dummies Questions & Answers 3 09-20-2009 12:40 AM
Difference between using "echo" builtin and /bin/echo ulidtko Shell Programming and Scripting 2 07-15-2009 12:12 PM
echo without newline character srilaxmi UNIX for Dummies Questions & Answers 2 11-10-2008 12:11 PM
replace a newline (\n) jeter Shell Programming and Scripting 3 05-18-2008 11:37 PM
newline Gale Gorman Forum Support Area for Unregistered Users & Account Problems 2 05-04-2008 01:23 PM



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