コマンドの実行結果を一行にまとめたり、一行になったものを複数行に分割したいことが有りますよね
tr コマンドで置換
tr コマンドは translate word で文字を移動させるものですが。
takuya@rena:~/Downloads$ echo "abcdefgabcabca" | tr abc xyz xyzdefgxyzxyzx
改行を置換
以下のコマンドは、with オプションを一覧するが、そのままだと使えない。
takuya@rena:~/Desktop$ brew info ffmpeg | grep ^--with | grep -v ^--without --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools
そこで一行にまとめる。
tr を使って複数行を一行にまとめる。
brew info ffmpeg | grep ^--with | grep -v ^--without | tr '\n' ' ' --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools