LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 10-05-2013, 12:00 PM   #1
lanssu
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
shell sed -i command


how i used shell "sed -i" command, replace file log,the file has null data in log file ?
 
Old 10-05-2013, 12:31 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by lanssu View Post
how i used shell "sed -i" command, replace file log,the file has null data in log file ?
The sed -i .... command changes in-place. If, for whatever reason, you make a mistake then the original file is (partially) gone.

You can force sed to make a backup:
Code:
sed -i.bak .....
Even safer would be to make a backup copy of the original file.
 
Old 10-17-2013, 05:01 PM   #3
bomba
LQ Newbie
 
Registered: Oct 2013
Posts: 5

Rep: Reputation: Disabled
Question dude

Hi!
I didn't understand the question.
what do you mean by "replace file log,the file has null data in log file ?"
can you explane the situation ?
 
Old 10-17-2013, 05:25 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
since sed is Stream EDitor, there is little point using it on an empty file, nothing to edit.

Give us more context,
what is the full sed command?
what is in the original file?

please use
[code]
your sample data here
[/code]

tags around your sed command, and input data ( what is in the logfile )
 
  


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
[SOLVED] Is it possible to use the matched string in sed as an input to shell date command? yadam Linux - Newbie 3 11-16-2012 12:59 AM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
Simple shell script - sed command Todd88 Programming 10 07-06-2008 04:33 PM
shell scripting problem, sed command kamkos Linux - General 5 03-31-2007 09:39 PM
shell command help, sed i think infamous41md Programming 2 08-15-2004 02:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 08:31 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