LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I actually delete a line using bash? (http://www.linuxquestions.org/questions/linux-general-1/how-do-i-actually-delete-a-line-using-bash-687501/)

gerben12 12-01-2008 01:11 PM

How do I actually delete a line using bash?
 
Hello,

I was wondering: how can I actually delete a line from a list with just one command?

Say I have this list:

ITEM1
ITEM2
ITEM3

Now I want to remove say ITEM2.
How can I do this in one command?
Yes, I can copy it then use "grep -v" or "sed 2d" and copy it back.
But is there one command that does this in one time?
It saves me a lot of copy and pasting :)

Thanks in advance.

colucix 12-01-2008 01:14 PM

Code:

sed -i '2d' file

gerben12 12-03-2008 02:54 AM

Yep thank you, that works.


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