LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 03-28-2013, 11:35 PM   #1
nicksu
Member
 
Registered: Dec 2012
Posts: 35

Rep: Reputation: Disabled
sed fill form


Hi,I have a CSV form to fill in,but when I use sed,it will cover or append the output line.can anyone help to solve it ?sed 'w file' or sed > file would also cover the lines which output before
 
Old 03-29-2013, 12:07 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Let's know your sample CSV form and commands that you've tried so far.
 
Old 03-29-2013, 12:57 AM   #3
nicksu
Member
 
Registered: Dec 2012
Posts: 35

Original Poster
Rep: Reputation: Disabled
hi,a -i work
 
Old 03-29-2013, 07:30 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
It appears that he's talking about how redirecting the output back into the same file will overwrite it.

This is true of all redirections, whatever the program. The ">" is processed and the file truncated before the command is ever run, so naturally you'll end up with an empty file. You almost always have to output to a different temporary file and then replace the original with it.

gnu sed has added the '-i' option, which overwrites the original, but in actuality it just directs the output to a background temp file first anyway. Also, it's not portable since other versions of the program don't have it.

If you want to do true text editing without working with tempfiles, then try using ed instead. It's an actual text editor; it loads the entire file into a memory buffer for editing, and can thus write it back to the original safely. It's also often easier to use when doing multi-line editing.

How to use ed:
http://wiki.bash-hackers.org/howto/edit-ed
http://snap.nlc.dcccd.edu/learn/nlc/ed.html
(also read the info page)

There's also ex, which has a similar mode of operation and is even more powerful. On Linux it's actually a shell interface for vim.
 
  


Reply



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
How can I save my time not to do the same repetitive job in a webpage to fill a form pokhraa Linux - Software 2 12-24-2011 04:39 PM
auto fill a form and submit using curl limadario Linux - Software 1 06-04-2010 05:46 AM
bash/sed/awk fill each line in text file with space to fixed length khairil Programming 11 01-09-2008 05:28 AM
PHP: build query from form entry, then display results in the same form tonedeaf1969 Programming 4 06-22-2007 07:55 AM
how do I copy a whoel folder form one directory to another form the command line? zwyrbla Linux - Newbie 8 08-24-2004 06:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:49 PM.

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
Open Source Consulting | Domain Registration