LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-09-2014, 01:18 PM   #1
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Rep: Reputation: Disabled
how to remove a line from a text file


Hi Linux Guru's

I'm trying to find ways on how can I remove lines from a file using "SED" but still the lines do still exists.


tried this command but didnt work = sed 'pogi' sudoers

I'm trying to remove this two line from sudoers (I am root)

# pogi is enabled
halaka ALL=(ALL) NOPASSWD:/opt/hal/bin/test.sh




please enlighten me on other options that can be used
 
Old 09-09-2014, 01:24 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,717

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Guessing doesn't work well with command line. Try reading the man page or online tutorials before using a command.
 
Old 09-09-2014, 02:30 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,598

Rep: Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060
Quote:
Originally Posted by apss_evaluator View Post
Hi Linux Guru's
I'm trying to find ways on how can I remove lines from a file using "SED" but still the lines do still exists.

tried this command but didnt work = sed 'pogi' sudoers

I'm trying to remove this two line from sudoers (I am root)

# pogi is enabled
halaka ALL=(ALL) NOPASSWD:/opt/hal/bin/test.sh

please enlighten me on other options that can be used
You've asked about sed before...have you not tried to read any documentation, or look this up??? Just putting "how to delete a line from a file using sed" into Google give you THOUSANDS of examples:
http://www.theunixschool.com/2012/06...e-line-or.html

Please try to do basic research on your own, before posting, and try to apply what you've been told in previous threads.
 
Old 09-09-2014, 02:34 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,388

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Use visudo, position cursor on first line to delete, type "dd" two times then ":wq", done
 
Old 09-09-2014, 03:07 PM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,076

Rep: Reputation: 861Reputation: 861Reputation: 861Reputation: 861Reputation: 861Reputation: 861Reputation: 861
maybe grep would be better suited:
Code:
grep -v "(pogi is enabled|halaka ALL=\(ALL\) NOPASSWD:/opt/hal/bin/test.sh)" /whatever/floats/your/boat
?
 
1 members found this post helpful.
  


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] Shell script to remove selected line number from text file. ChocaMocha Programming 4 04-25-2013 03:11 PM
[SOLVED] remove specified line from text ted_chou12 Linux - Newbie 7 02-12-2011 03:34 AM
Remove New Line or Carriage return from Text File DIMonS Programming 13 10-01-2007 10:31 AM
How to remove line of text from file netkepala Linux - General 2 05-23-2003 11:49 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