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 01-26-2011, 10:59 AM   #1
520Soul
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Rep: Reputation: 0
how to update a file in bash


hi guys. I have been looking for some example of how to update a file that is already exist in bash. so far i haven found any. I'm using parameter as my first start for the existent, copy file to a different directory. can you guys help me please, show me some example of anyway to update a file.

thanks ahead guys..
 
Old 01-26-2011, 11:02 AM   #2
goossen
Member
 
Registered: May 2006
Location: Bayern, Germany
Distribution: Many
Posts: 224

Rep: Reputation: 41
I'm not sure if I understood correctly your question. But if you wanna edit a file check the command sed.
 
Old 01-26-2011, 01:18 PM   #3
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
@520Soul
Greetingz!

This kindof depends on the contents of the file in question, and exactly what you want to change. For example, as goossen pointed out, sed can really help out.
Sed One-Liners Explained, Part I
Sed One-Liners Explained, Part II
Sed One-Liners Explained, Part III
There's also awk, cut, grep, and a slew of other commands. Again it all boils down to what you're trying to do to the file in question.
(Some sample output would be nice, along with what you're trying to accomplish)
 
Old 01-26-2011, 03:07 PM   #4
520Soul
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Original Poster
Rep: Reputation: 0
sorry for bad description.

Quote:
Originally Posted by goossen View Post
I'm not sure if I understood correctly your question. But if you wanna edit a file check the command sed.



for instant, a file1 have data A,b,c. now file1 is re-written. and you want to update it. i think update and replace is the same right? i'm not sure if the word update is the correct word. it is like the file is old and you want to replace the old file with new one. does it has to have the same file name? i don't think it matter right?
 
Old 01-26-2011, 03:35 PM   #5
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 584

Rep: Reputation: 59
Quote:
Originally Posted by 520Soul View Post
for instant, a file1 have data A,b,c. now file1 is re-written. and you want to update it. i think update and replace is the same right? i'm not sure if the word update is the correct word. it is like the file is old and you want to replace the old file with new one. does it has to have the same file name? i don't think it matter right?

Try this, in the same sequence, to understand some file operations:

Code:
#cal > myCal <ENTER>
#cat myCal <ENTER>
#date > myCal <ENTER>
#cal >> myCal <ENTER>
 
Old 01-26-2011, 04:48 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,093

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
the obvious would be cp, mv, rm, ...
 
  


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
[SOLVED] How write a literal bash command in a bash file? xeon123 Linux - Newbie 6 11-29-2010 12:05 PM
Update csv file into mysql db via bash script xmrkite Linux - Software 4 01-13-2010 12:43 AM
Sed doesn't update file in bash script chilebiker Programming 4 06-14-2007 08:25 AM
bash errors after update JonathonReinhart Linux - Software 13 01-21-2006 12:48 PM
Yum Update complains of missing file to do update, but file exists! davidas Linux - Newbie 0 03-28-2004 11:14 AM


All times are GMT -5. The time now is 05:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration