how can delete certain word from file
I have text file which has 1 word per line , but there are lines which has word from 1 or 2 character like as in on ,etc. I want to delete this word from my file, how can i do that.
|
sed '/<word_to_delete>/d' -i <filename>
|
thank you, but i want to delete every word contain just 1 or 2 character , there are many word , how can do that?
|
Oh, sorry, didn't get your question at first.. This
sed '/^..$/d' -i <filename> should remove all lines that comtain only two characters. Similarly for 1-character lines sed '/^.$/d' -i <filename> |
thank you,
now, i have 2 file , i want to know which word that locate in two file? |
Do you want to know which file contains a specific word? Then you need the grep command.
Or, are you asking which words will the abovementioned commands delete? I didn't quite get your question, sorry. |
look
first file 1.txt has some words , 2nd file 2.txt has some words , both file has some same words , i want to know this words. thank very much |
Well, the only thing I can come up with is something like this
sort textfile.txt > tempfile1 && sort textfile1.txt > tempfile2 && comm tempfile1 tempfile2 && rm tempfile1 tempfile2 Also, you might wanna look at man comm |
Is this homework? Sure sounds like homework the way your asking your questions and not being very clear on your questions, then coming up with more questions?
|
thank you Uncle_Theodore
Mr trickykid, this is not home work , i am already graduating from univ. And it is not my habit to ask many, but my knowledge about text processing is not good, that set. Mr trickykid, do't accuse from your imagination without ask me first , because life is not standard case. |
Quote:
|
I 2nd to trickykid's suspicious.
Quote:
And you can go further on other File/Text Processing Tools as well. |
All times are GMT -5. The time now is 10:59 PM. |