mac lessコマンド実行時に行番号を表示する

  • 作成日 2022.10.15
  • mac
mac lessコマンド実行時に行番号を表示する

macで、コマンドを実行して、lessコマンド実行時に行番号を表示する手順を記述してます。

環境

  • ProductName: macOS
  • ProductVersion: 11.5.2
  • BuildVersion: 20G95

行番号を表示

「less」コマンド実行時に行番号を表示するには、オプション「-N」を使用します。

例えば「httpd.conf」を「less」コマンドで行番号を表示して、確認する場合は以下となります。

less -N httpd.conf

実行結果

ちなみに「cat」の場合は「-n」となります。

cat -n httpd.conf

<出力結果>
     1  #
     2  # This is the main Apache HTTP server configuration file.  It contains the
     3  # configuration directives that give the server its instructions.
     4  # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
     5  # In particular, see 
     6  # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
     7  # for a discussion of each configuration directive.
     8  #
     9  # Do NOT simply read the instructions in here without understanding
    10  # what they do.  They're here only as hints or reminders.  If you are unsure
    11  # consult the online docs. You have been warned.  
    12  #
    13  # Configuration and logfile names: If the filenames you specify for many
    14  # of the server's control files begin with "/" (or "drive:/" for Win32), the
    15  # server will use that explicit path.  If the filenames do *not* begin
    16  # with "/", the value of ServerRoot is prepended -- so "logs/access_log"
    17  # with ServerRoot set to "/usr/local/apache2" will be interpreted by the
    18  # server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" 
    19  # will be interpreted as '/logs/access_log'.
    20
    21  #
    22  # ServerRoot: The top of the directory tree under which the server's
    23  # configuration, error, and log files are kept.
    24  #
    25  # Do not add a slash at the end of the directory path.  If you point
    26  # ServerRoot at a non-local disk, be sure to specify a local disk on the
    27  # Mutex directive, if file-based mutexes are used.  If you wish to share the
    28  # same ServerRoot for multiple httpd daemons, you will need to change at
    29  # least PidFile.
    30  #
    31  ServerRoot "/usr"
    32
    33  #
    34  # Mutex: Allows you to set the mutex mechanism and mutex file directory
    35  # for individual mutexes, or change the global defaults
    36  #
    37  # Uncomment and change the directory if mutexes are file-based and the default
    38  # mutex file directory is not on a local disk or is not appropriate for some
    39  # other reason.
    40  #
    41  # Mutex default:/private/var/run
    42
    43  #
    44  # Listen: Allows you to bind Apache to specific IP addresses and/or
    45  # ports, instead of the default. See also the <VirtualHost>
    46  # directive.
    47  #
    48  # Change this to Listen on specific IP addresses as shown below to 
    49  # prevent Apache from glomming onto all bound IP addresses.
    50  #
    51  #Listen 12.34.56.78:80
    52  <IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
    53      Listen 8080
    54  </IfDefine>
    55  <IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
    56      Listen 80
    57  </IfDefine>
    58
    59  #
    60  # Dynamic Shared Object (DSO) Support
    61  #
    62  # To be able to use the functionality of a module which was built as a DSO you
    63  # have to place corresponding `LoadModule' lines at this location so the
    64  # directives contained in it are actually available _before_ they are used.
    65  # Statically compiled modules (those listed by `httpd -l') do not need
    66  # to be loaded here.
    67  #
    68  # Example:
    69  # LoadModule foo_module modules/mod_foo.so
    70  # LoadModule my_custom_module /usr/local/libexec/mod_my_custom.so "My Signature Authority"
    71  #
    72  #LoadModule mpm_event_module libexec/apache2/mod_mpm_event.so
    73  LoadModule mpm_prefork_module libexec/apache2/mod_mpm_prefork.so
    74  #LoadModule mpm_worker_module libexec/apache2/mod_mpm_worker.so
    75  LoadModule authn_file_module libexec/apache2/mod_authn_file.so
    76  #LoadModule authn_dbm_module libexec/apache2/mod_authn_dbm.so
    77  #LoadModule authn_anon_module libexec/apache2/mod_authn_anon.so