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
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
Cat'ing a multiple line file to one line djsal Shell Programming and Scripting 1 04-16-2007 09:50 PM
Appending the line number and a seperator to each line of a file ? pjcwhite Shell Programming and Scripting 4 03-21-2007 01:29 AM
Remove header(first line) and trailer(last line) in ANY given file madhunk Shell Programming and Scripting 2 03-13-2006 03:36 PM
How to read from a file line by line and do stuff spaceship Shell Programming and Scripting 4 03-17-2005 09:47 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 06-21-2006
sandeep_hi sandeep_hi is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 29
How to add a new line into a file

I want to insert a new line character inside the file between these two record entries "san" and "man". How can this be done

echo " san " >"C:/\Test/\Output/\Neme"
echo " man " >>"C:/\Test/\Output/\Name"


Name file should look like this
san
man

Please help
  #2 (permalink)  
Old 06-21-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
The echo command should by default be putting a newline char at the end of each line. But if it isn't, you can specify the newline char, like this:
Code:
echo " san \n"

  #3 (permalink)  
Old 06-21-2006
sandeep_hi sandeep_hi is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 29
echo " san \n"
gives the following output

san \n

but when we use echo -e " san \n" it gives the desired output on the screen but while inserting into the file it doesn't work.

Please help me how to make it work

Regards
Sandeep

Last edited by sandeep_hi; 06-22-2006 at 03:33 AM..
  #4 (permalink)  
Old 06-22-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960
Quote:
echo " san \n"
gives the following output

san \n
strange,
it should only be


Code:
san
<newline>
<prompt>

  #5 (permalink)  
Old 06-22-2006
sandeep_hi sandeep_hi is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 29
Actually i am using cygwin and the problem was in the editor(notepad) which was not displaying it correctly. When i opened the same file in wordpad the display was as desired.

Thanks
Sandeep
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 11:59 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