Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のようなテキストファイルがあります。
word1 & wordff 39 0: sgfdgggg, sgdgsd word23 & sgfdgsdgsdgdg 44 0: sgdggfg, sfgdgdg word45 *
そして、私はこれが必要です:
word1 & word23 & word45 *
どうすればGREPでそれを行うことができますか?
grep -Eo '.*?[&*#]'
例えば:
kent$ echo "word1 & wordff 39 0: sgfdgggg, sgdgsd word23 & sgfdgsdgsdgdg 44 0: sgdggfg, sfgdgdg word45 *"|grep -Eo '.*?[&*#]' word1 & word23 & word45 *