0

私の質問は単純です。特に、Vim の Tabularize プラグインに精通している人にとっては。シェル内の別のコマンドから取得した出力を表にしたいと考えています。たとえば、特定の出力を生成する次のコマンドがあるとします。

$ mpc playlist
Metallica - Ride the lightning - The call of Ktulu
Metallica - Master of puppets - Master of puppets
Metallica - Master of puppets - Orion (Instrumental)
Nirvana - Nevermind - Smells like teen spirit
Metallica - ...And justice for all - One
Metallica - ...And justice for all - ...And justice for all
Metallica - Kill'em all - Seek and destroy
Metallica - Metallica - Wherever I may roam
Metallica - Metallica - The god that failed

必要なのは、この出力をパイプして次のように取得できるコマンドです

$ mpc playlist | tabularize --delimiter=" - "
Metallica - Ride the lightning     - The call of Ktulu
Metallica - Master of puppets      - Master of puppets
Metallica - Master of puppets      - Orion (Instrumental)
Nirvana   - Nevermind              - Smells like teen spirit
Metallica - ...And justice for all - One
Metallica - ...And justice for all - ...And justice for all
Metallica - Kill'em all            - Seek and destroy
Metallica - Metallica              - Wherever I may roam
Metallica - Metallica              - The god that failed

何か案は?

4

2 に答える 2

0

探しているコマンドはcolumn.

試してみてくださいmpc playlist | column -t -s '-' -o '-'

'-'悲しいことに、入力に文字がある場合、これは機能しません。指定する' - 'と、文字列全体ではなく、スペースでも列化されます。

于 2013-07-13T14:25:45.060 に答える