LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash - delete lines that starts with one particular lettere from a file (http://www.linuxquestions.org/questions/linux-newbie-8/bash-delete-lines-that-starts-with-one-particular-lettere-from-a-file-4175448750/)

Hoxygen232 02-05-2013 03:12 PM

bash - delete lines that starts with one particular lettere from a file
 
Hi,

What I want to do is:
I have a "file.txt" like this:
Code:

hi
mom
zzz
the
pasta
tomorrow
night
zorro
zheta
zing

I need to delete all words that starts with 'z', so after remval it will be:
Code:

hi
mom
the
pasta
tomorrow
night

so I need to delete from the same file which I read from, and there must not be empty lines after removal.

Is it possible?
thanks a lot

colucix 02-05-2013 03:17 PM

Maybe by means of something like this?
Code:

sed -i '/^z/d' file

Hoxygen232 02-05-2013 03:19 PM

great, it works perfect thanks


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