LinuxQuestions.org
Register a domain and help support LQ
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-02-2009, 01:58 PM   #1
nagaraj
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
how to delete a line from a file using sed


hi
i tried this
variable=10
sed -i '$variable"d temp.txt

here i want to accept input and delete that particular line
but it gives error
 
Old 09-02-2009, 02:04 PM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,811
Blog Entries: 1

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Try

Code:
sed -i "$var"d temp.txt
 
Old 09-02-2009, 02:09 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Or
Code:
sed -i "${var}d" file
just in case :}
 
  


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
Delete next line in sed Yalla-One Programming 9 01-04-2009 05:00 PM
sed to delete a line for a word and line above cmontr Programming 11 07-03-2008 09:33 AM
SED - Delete line above or below as well as matching line... OldGaf Programming 7 06-27-2008 12:51 AM
using sed to delete line to the right khairilthegreat Linux - Newbie 5 07-28-2007 03:10 PM
[SOLVED] delete the end of each line in a file with sed angel115 Linux - Newbie 3 11-16-2005 05:41 PM


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