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.
sed を使用して、ファイルの行にスペース文字がある場合、スペース文字とそれを削除した後の出力を出力する必要があります。コード例:
sed "s/"something here I think"//g' file
それで、ファイルが行でこれを言うとしましょう:
Chuck Norris is the man
印刷するだけです:
Chuck
複数行も適用可能:
Chuck Norris is the man So is Arnold
置換:
Chuck So
これでうまくいくはずです:
sed 's/ .*//g' file
行頭から最初のスペースまでを削除するには、次のようにします。
sed 's/^[^ ]* //g'