grepとsedで特定のディレクトリ以下のファイルを一括置換

特定のディレクトリ内のファイルで特定の文字を一括置換するには「grep」と「sed」をコマンドを利用すると一括で置換できます
書式:grep -rl “置換対象 ...
Zabbixのバージョンを確認する方法

Zabbix Server・Zabbix Agent のバージョンを確認する方法を紹介します。CUIからコマンドで確認する方法とWEB管理画面での確認方法を紹介します
zabbix_serve ...Zabbix でメンテナンス期間を設定する

Zabbix 6.4で、Apache等バージョンアップ・バッチ処理等で、サービス停止を伴うメンテナンスを行う場合があります。その際にZabbixよりアラート通知が飛んできたりするのでメンテンス中はアラートを停止するメンテンス時間を指定 ...
zabbix-getコマンドがみつからない

Zabbix6.4でZabbix エージェントからデータを取得するためのコマンドラインユーティリティの「zabbix_get」を使おうと思いましたが、zabbix_get コマンドがあり ...
php-fpmのログファイルのログレベルについて

古いWordpressのブログがあって使用しているプラグインが古いので「/var/log/php-fpm/www-error.log」に下記のWarningのエラーが大量に出力されていました。このWarningを出力しないようにログレ ...
rsyncで所有者・グループを同期しないでコピー

リモート先のWEBコンテンツをバックアップ用途でrysncでコピーします。
リモート先のファイル等の所有者・グループは同期してもいいですが、ファイル・ディレクトリの所有者が「apache」だったりFTPユーザーとか複数の所 ...
SCPコマンドでタイムスタンプ・パーミッションを保持してコピー

いつもサーバー間のデータコピーは、scpコマンドを利用しています。「-r」のオプションをつかって、ディレクトリ以下のファイルやディレクトリを再帰的に取得してコピーしてました。
ファイルのタイムスタンプやパーミッションを保持 ...
grepで2桁の数字を含む行を抽出する

grepコマンドで2桁の数字を含む行を抽出する場合は、下記のコマンドで数字を2桁の行を抽出できます
grep -E "{2}"下記のような数字を含むテキストファイルで、2桁 ...
gz形式のファイルを解凍しないで中身を確認する

ローテーションしているログファイルで、古いログはgz形式で以下のように圧縮している場合があると思います。
$ sudo ls/var/log/mariadb/mariadb.log mariadb.log-20230922.gz ...lsコマンドで、容量が大きいサイズ順にソートする方法

容量関係でついでですが、lsコマンドで容量が大きい順にソートするのは「-S」オプションを使用します
この「-S」コマンドは、ファイルやディレクトリを容量の大きい順にリ ...
CentOS系でファイル名の文字を置換してファイル名を変換

CentOS系で、「test_01.txt」等のファイルが有り「test01.txt」の用に「_」を省略したいときがあります。「mv」コマンドでもで ...
sedコマンドで「/」 と 「&」を含む場合のエクケープ処理

シェルスクリプト内でテキストファイル内の一部の文字を置換する処理があって、半角空白と「&」を含んでいて、置換がうまく処理されずに変数名が残ってしまいました
$ cat in.txtCORPORATION 御中$ sh s ...永続オブジェクトキャッシュを使用してください 【WordPress】

Wordpressのヘルスチェックで下記のように「永続オブジェクトキャッシュを使用してください」と表示されます。以前は「Memcached Redux」を使ってい ...
ディレクトリ内にある、空白のファイル名を変換する

任意のディレクトリにある、空白を含むファイル名をアンスコ(_)やハイフン(-)に変換する方法ですが、ネットでは以下のワンライナーの方法がありました
find . -name "* *" | rename 's//_/g'C ...
csvファイルの指定したカラムの空白文字を変換する

csvファイルで指定したカラム内の値がファイル名でWindowsだと良いのですが、Linuxだと良くないので半角の空白をアンスコ(_)やハイフン(-)に変換したくて、シェルスクリプトで頑張って色々とやってみましたがうまくいきませんでし ...