0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

たくさんのスペースで区切られた文字列のうち一番最後のフィールドを取得したい(`cut -f`オプションには最後のフィールドを取得するオプションがない..)

Posted at

以下のようにコマンド実行した際、たくさんのスペースで区切られた文字列のうち一番最後のフィールドを取得したい(cut -fオプションには最後のフィールドを取得するオプションがない..)

$ brew list --versions | grep qt 
qt 5.13.0 5.13.1 5.14.2

revコマンドを使えばよい

brew list --versions | grep qt | rev | cut -d' ' -f1 | rev
python -V | rev | cut -d' ' -f1 | rev
5.14.2
3.7.1

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?