24
13

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 3 years have passed since last update.

AWS CLI v2 の実行結果を less, more で表示したくない場合

Posted at

結論

大抵の場合、下記コマンドで OK

% aws configure set cli_pager ''

どういう事か

今までの AWS CLI v1 はデフォルトでページャー無し表示だったが、AWS CLI v2 では実行結果の表示はデフォルトで less, more が使用される。
AWS CLI v2 でページャー無し表示したい場合には設定が必要。

Breaking Changes – Migrating from AWS CLI version 1 to version 2 - AWS Command Line Interface
https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html#cliv2-migration-output-pager

By default, AWS CLI version 2 returns all output through your operating system’s default pager program. By default this program is the less program on Linux and macOS, and the more program on Windows. This can make it easier for you to navigate a large amount of output from a service by displaying that output one page at a time. However, you sometimes want all the output without needing to press a key to get each page, such as when you are running scripts. To do this, you can configure the AWS CLI version 2 to use a different paging program or none at all. To do this, configure either the AWS_PAGER environment variable or the cli_pager setting in your ~/.aws/config file and specify the command you want to use. You can specify a command that is in your search path, or specify the full path and file name for any command available on your computer.

設定方法は下記の2つ

  1. 環境変数 AWS_PAGER を空として設定する方法
  2. ~/.aws/configcli_pager を空で設定する方法

で、大抵の場合2つ目の方法がマッチするはず・・・
~/.aws/config ファイルを自前で書き換えても良いものの、 AWS CLI には config 設定を行うコマンドとして aws configure set コマンドがあるので、これを使って設定する。

set — AWS CLI 1.17.17 Command Reference
https://docs.aws.amazon.com/cli/latest/reference/configure/set.html

Set a configuration value from the config file.

というわけで、下記のコマンドで OK

% aws configure set cli_pager ''

profile 指定したい場合

% aws configure set cli_pager '' --profile myprofile

パッと反映されているか確認したい場合、 describe-regions がシンプルで良い

% aws ec2 describe-regions

describe-regions — AWS CLI 1.17.17 Command Reference
https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-regions.html

おわり。

24
13
1

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
24
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?