3
3

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

head *やtail *がファイルをざっと見るのに便利

Posted at

例えば /etc/●●.d/ といったディレクトリで設定ファイルなどが細分化されていて、目視でざっと中身を把握したい場合があります。
そんな時は cat * などではなく head *tail * といったコマンドのほうが綺麗になります。
確認はCentOS 7です。

コマンド
head -n999 /etc/httpd/conf.modules.d/*
出力
==> /etc/httpd/conf.modules.d/00-base.conf <==
#
# This file loads most of the modules included with the Apache HTTP
# Server itself.
#

LoadModule access_compat_module modules/mod_access_compat.so
(999行表示を指定しておきながら、いざ出したら長かったので省略)
# LoadModule sed_module modules/mod_sed.so
# LoadModule speling_module modules/mod_speling.so


==> /etc/httpd/conf.modules.d/00-dav.conf <==
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_lock_module modules/mod_dav_lock.so

==> /etc/httpd/conf.modules.d/00-lua.conf <==
LoadModule lua_module modules/mod_lua.so

==> /etc/httpd/conf.modules.d/00-mpm.conf <==
# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines:

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
# LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
# LoadModule mpm_event_module modules/mod_mpm_event.so


==> /etc/httpd/conf.modules.d/00-proxy.conf <==
# This file configures all the proxy modules:
LoadModule proxy_module modules/mod_proxy.so
(省略)
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so

==> /etc/httpd/conf.modules.d/00-systemd.conf <==
# This file configures systemd module:
LoadModule systemd_module modules/mod_systemd.so

==> /etc/httpd/conf.modules.d/01-cgi.conf <==
# This configuration file loads a CGI module appropriate to the MPM
# which has been configured in 00-mpm.conf.  mod_cgid should be used
# with a threaded MPM; mod_cgi with the prefork MPM.

<IfModule mpm_worker_module>
   LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_event_module>
   LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
   LoadModule cgi_module modules/mod_cgi.so
</IfModule>


==> /etc/httpd/conf.modules.d/10-php.conf <==
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>


==> /etc/httpd/conf.modules.d/passenger.conf <==
LoadModule passenger_module /usr/lib64/ruby/gems/2.1.0/gems/passenger-4.0.59/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/lib64/ruby/gems/2.1.0/gems/passenger-4.0.59
  PassengerDefaultRuby /usr/bin/ruby
</IfModule>

とこんな感じでファイル名の見出しを付けてくれます。

使い所

複数階層まとめて
tail -n999 /etc/httpd/*/*.conf
検索条件を増やしたくなったらfindとxargsで
find /etc/ -mtime -1 -name \*.conf | xargs tail -n999
ローテートされてないアクセス&エラーログをまとめて
tail /var/log/httpd/*_log
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?