LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 11-26-2015, 12:05 PM   #1
Bobbic
LQ Newbie
 
Registered: Nov 2015
Posts: 4

Rep: Reputation: Disabled
Why is the sed-Order not saving the changes in the .dat file?


Hey Guys,

i have a problem with the sed order. I want to delete the first 5 lines of my file file.dat.

I use

Code:
sed -e  "1,5d" "file.dat"
to solve it. The console shows the correct result but the deleted lines are not saved in the file.dat. If i open the file.dat it contains the 5 lines.

Do you know why?
 
Old 11-26-2015, 01:12 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,437

Rep: Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842
Check out the man page (hint: you need another switch )
 
Old 11-26-2015, 08:06 PM   #3
merritt
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
this looks like the only place to reply....you guys are nothing but a bunch of idiots...[removed]
 
Old 11-27-2015, 02:52 AM   #4
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,689

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by Bobbic View Post
Hey Guys,

i have a problem with the sed order. I want to delete the first 5 lines of my file file.dat.

I use

Code:
sed -e  "1,5d" "file.dat"
to solve it. The console shows the correct result but the deleted lines are not saved in the file.dat. If i open the file.dat it contains the 5 lines.

Do you know why?
You misunderstand the way sed and the other UNIX text processing tools work. sed takes some input, processes it and writes it to the output.

There is indeed a switch that changes this behaviour - -i. Yes, do check the man page or, perhaps better, the sed manual https://www.gnu.org/software/sed/manual/sed.html.
 
Old 11-27-2015, 10:15 AM   #5
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,267

Rep: Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202
merritt, that kind of language isn't acceptable at LQ. Please refrain from it in the future.

--jeremy
 
  


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
saving all the bookmarks of FireFox - in order to move the stuff to another machine sayhello_to_the_world Linux - Newbie 5 07-23-2013 07:28 AM
Saving state/ensuring order/one time execution in functional languages Sergei Steshenko Programming 2 06-30-2012 01:06 PM
How to make alterations to a file using sed , saving changes and retaining filename ? uncle-c Linux - General 2 07-02-2009 10:46 AM
what is the correct syntax order for tar with --after-date DATE, --newer DAT farhan Linux - General 1 03-16-2007 08:43 AM
saving a file after SED bajaj111 Linux - Software 3 11-07-2006 10:32 AM


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