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
Copying Text between two unique text patterns spindoctor UNIX for Dummies Questions & Answers 3 01-16-2009 03:42 AM
c program to extract text between two delimiters from some text file kukretiabhi13 High Level Programming 7 12-03-2008 06:29 PM
Building Full-Text Search Applications with Oracle Text iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
text formating/Text space padding hugow UNIX for Dummies Questions & Answers 6 06-29-2005 09:49 AM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 02:50 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 05-31-2007
leeRoberts2007 leeRoberts2007 is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
add text to end of text file

Hi,

I assume there is a simple solution, but as usual i can't find it!
How can i add a line of text to the end of a text file on a new line?

i.e
file.txt
________________
this is my text file
________________

file.txt
________________
this is my text file
WITH A NEW LINE
________________

Thanks for your time

Lee
  #2 (permalink)  
Old 05-31-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
LeeRoberts,
Here is one way of doing this:
Code:
(cat input_file ; echo "WITH A NEW LINE") > output_file
  #3 (permalink)  
Old 05-31-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
Code:
echo "WITH A NEW LINE" >> file
  #4 (permalink)  
Old 05-31-2007
leeRoberts2007 leeRoberts2007 is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
thanks, and how about something at the start of a text file?
  #5 (permalink)  
Old 05-31-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Code:
sed '1i yourline' file
  #6 (permalink)  
Old 05-31-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
Another method

Code:
cat file | awk ‘BEGIN {print “This is my first line”} {print $0}’ > file
  #7 (permalink)  
Old 05-31-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Quote:
Originally Posted by lorcan
Code:
cat file | awk ‘BEGIN {print “This is my first line”} {print $0}’ > file
UUOC
Code:
awk 'BEGIN {print "This is my first line"}{print $0}' file > file3322
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:21 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