したがって、sed がファイル内のすべての単語の検索と置換に優れていることは誰もが知っています。
sed -i 's/original_word/new_word/g' file.txt
しかし、誰かがファイルから 'original_words' のリストを sed にフィードする方法を教えてもらえますか (grep -f と同様)。すべてを '' (消去) に置き換えたいだけです。
元の単語リスト ファイルは、行で区切られた一連のストップワードです (wordlist.txt):
a
about
above
according
across
after
afterwards
これは、ストップワードのリストを取得してコーパスから削除する簡単な方法です (データのクリーニングに役立ちます)。
file.txt は次のようになります
05ricardo RT @shakira: Immigration reform isn't about politics. It's about people mothers, kids. Obama is working for all of them. http://t.co/rAW ... 0
05ricardo ?@ItsReginaG: Don't vote Obama. Because you will lose jobs, and die.? Lol 0
05ricardo ?@shakira: Obama doubles Pell Grants - 700,000 more Latinos get help to go to college. Meet Johanny Adames http://t.co/EMg8NLGl Shak?. ? -1
05rodriguez_a My Comm teacher gave me a copy of Obama's speech that he gave the other night and I cried while reading it. It was that moving. -3