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.
こんにちは、BSD sed で次のことを実行するにはどうすればよいですか?
sed 's/ /\n/g'
マンページから、 \n は置換文字列内で文字通り扱われると記載されていますが、この動作を回避するにはどうすればよいですか? 代替品はありますか?
私は Mac OS Snow Leopard を使用しています。GNU sed を入手するために fink をインストールするかもしれません。
シェルでは、次のことができます。
sed 's/ /\ /g'
バックスラッシュの後に Enter キーを押して、改行を挿入します。
Another way:
sed -e 's/ /\'$'\n/g'
See here.
使いやすさのために、私は個人的によく使用します
cr="\n" # or (depending version and OS) cr=" " sed "s/ /\\${cr}/g"
したがって、1行のままです。