Help us understand the problem. What is going on with this article?

「そこは less で表示してほしくない!」という時に使える cat

More than 1 year has passed since last update.

Git の pager に less を指定している場合など、何もしないと less で表示される場合があります。便利なのですが、行番号が表示されたりと不便なこともあります。

1 コマンドだけそれを解除する方法です。

やり方

最後に | cat - をつけるだけ。

console
# git diff # => less で表示されてしまう
git diff | cat - # => コンソールに表示される

使いどころ

自分は git diff --name-only でファイル名をターミナルからコピーしたいときに使います。

どうしてこうなる

パイプに流すと less で表示されず、標準入力をそのまま出力する cat - でコンソールに出力しています。

終わりに

コピー用途なら pbcopyclip を使うほうが楽だと思います。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away