LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 06-19-2002, 08:59 AM   #1
d-rez
LQ Newbie
 
Registered: May 2002
Distribution: RH 7.2
Posts: 18

Rep: Reputation: 0
append to file


I have a text file and I want to add a text satement everyday
to it.

what is the command to append text to the top of a file.

example

%more test.txt

f;kfjaslfkjdsfkja;
kfjskafj;sldf
asdkjfkdsjfkl;sdf;k
dlkfjasd;jfs;djf;
lk;djfakl;sjf;lskfj
lksjdfl;sajf;

I want to add 10/15/02 at the top of this file

Thanks in advance
 
Old 06-19-2002, 10:48 AM   #2
hanzerik
Member
 
Registered: Jan 2002
Location: Cheyenne Wyoming
Distribution: Debian/Raspbian/Mint
Posts: 717

Rep: Reputation: 32
Well I dont know if you can put the text at the top, but you can append to the bottom with:
echo "10/15/02" >> test.txt
 
Old 06-20-2002, 05:55 AM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
Well like hanzerik said you can't append to the top of a file, but you could do something like this:

Code:
#/bin/bash
{
  echo "10/15/02"
  cat test.txt
} > test.bak
mv -f test.bak test.txt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash programming-append single line to end of file pheasand Linux - General 4 02-28-2014 10:41 AM
c++ append data to file blizunt7 Programming 3 07-04-2005 01:47 AM
> writes a new file, how to append? luwigie Linux - General 1 08-26-2004 09:42 PM
pipe output to append to a text file davee Linux - Newbie 3 08-27-2003 06:03 AM
tar append file juno Linux - General 5 10-24-2002 03:59 AM


All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration