The UNIX and Linux Forums  

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
writing to a csv file pstanand Shell Programming and Scripting 6 03-27-2008 06:47 AM
Writing to a File using pl/sql stky13 High Level Programming 1 02-22-2008 08:45 AM
Reading a file and writing the file name to a param file. thebeginer UNIX for Advanced & Expert Users 1 10-05-2007 05:38 PM
writing to a file using awk gfhgfnhhn Shell Programming and Scripting 7 09-15-2006 10:52 AM
Writing to another file dreams5617 Shell Programming and Scripting 3 07-05-2006 02:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2006
dhananjaysk dhananjaysk is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 35
Writing to a file in different way

HI all,

If I have 3 lines in variables such as follows
x=Unix Forum
y=Interactive Forum
z=Unix Forum is Best Forum

Now I want to write these 3 lines in a file
so that that file will look like

Unix Forum
Interactive Forum
Unix Forum is Best Forum

How can I do it ?
--------------------------------------
Presently I am writing to it as follows
$x $y $z > a.out

But it shows all 3 lines in a single line...

Thanks.....In Advance
  #2 (permalink)  
Old 04-11-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
echo "$x\n$y\n$z" > a.out
  #3 (permalink)  
Old 04-11-2006
dhananjaysk dhananjaysk is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 35
Not working

Quote:
Originally Posted by mahendramahendr
echo "$x\n$y\n$z" > a.out
NO ...man its not working at all
  #4 (permalink)  
Old 04-11-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
$ x="mah"
$ y="abc"
$ z="123"
$ echo "$x\n$y\n$z" > a.out
$ more a.out
mah
abc
123


I guess you are trying to do something else other than what you have mentioned above... can you post your full script here and the output
  #5 (permalink)  
Old 04-11-2006
Rakesh Ranjan's Avatar
Rakesh Ranjan Rakesh Ranjan is offline
Registered User
  
 

Join Date: Aug 2005
Location: India
Posts: 42
Mahendramahendr, he may be right for the man page on echo says about option [e] as below :
-e enable interpretation of the backslash-escaped characters

Dhananjay try this
echo -e "$x\n$y\n$z" >a.out
And tell us if this works
Closed Thread

Bookmarks

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 07:38 AM.


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