macOSでバックスラッシュの入力方法

プログラミングで禁則文字をエスケープする場合によく使用する「バックスラッシュ」の入力方法です。「\」はJISのキーボードを使用している場合は「option」+「¥」キーで入力できます。
sed コマンドで上書き保存(macOS)

sedコマンドで文字を置換して上書き保存するように「sed -i ‘s/置換前/置換後/g’ (ファイル名)」とコマンドをうっても以下のようにエラーになります ...
ダブルクリックでシェルスクリプトを実行する(macOS)

シェルスクリプトを作って、「test.sh」として実行権限を付与しターミナルからだとシェルスクリプトは動作しましが、ファイルをダブルクリックしてもテキストエディタ等が起動してシェルスクリプトの ...
sshログインすると「POSSIBLE BREAK-IN ATTEMPT!」のエラー表示

sshでログインすると下記のように「but th ...
ファイル内の特定の文字を含む行を削除する

ファイル内で特定の文字列を含む行を削除するには、「awk」, 「grep」 , 「sed」コマンドで削除できますが、今回は「sed」コマンドを利用した場合の方法を紹介します」
下記 ...
シェルスクリプトでファイルが空かどうか確認する

シェルスクリプトでファイルが空ファイル(0byete)かどうか確認する場合はifコマンドの「-s」のオプションを利用します。
$ sh test.sh#!.bin/bashFILE=te ...Let’s Encryptで古い各種証明書を自動で削除する

Let’s Encryptの証明書の有効期限が90日なので、1月に1回Cronで更新作業をおこなっています、そうすると新しいファイルは/etc/letse ...
シェルスクリプトを利用して、logmonで除外キーワードを設定

logmonのログ監視では、指定した文字列のみヒットするとメールを送付する、任意のシェルスクリプトを実行するなどのアクションが実行できます。
※ logmonのインストール方法は「l ...
cpコマンドで確認なしでコピー

通常ではcpコマンドはコピーする際にcp -f (コピー元) (コピー先)として確認不要でコピーしても、下記のように確認コマンドが出る場合あります
$ cp -f hoge.txt ...CentOS 6.x 系で、MySQL5.1からMySQL5.6にバージョンアップする

CentOS 6.x系のMySQLのバージョンは、「mysql-5.1系」で.「mysql-5.6系」を使用したい場合に、yumでのインストール方法を紹介します
1,M ...
Finderのタグを削除する(macOS)

ファイルやフォルダを探しやすくするためにタグでファイル・フォルダを整理していますが、macOSをバージョンアップしたら勝手にタグが増えてきたので使用していない削除しました。
タグを削 ...
macOSのターミナルでログインすると「LC_CTYPE: cannot change locale 」と表示される

CentOSなどのLinuxサーバにターミナルソフトやiTermでSSHを使ってログインすると、「LC_CTYPE: cannot ...
macOS Mojave ダークモード・ライトモードの変更方法

macOS Mojaveの追加機能の「ダークモード」が追加されましたので、そのダークモードの変更方法を紹介します。
macOS Mojaveのインストールは、アップデートをおこ ...
強制的にハードディスクを外す(macOS)

Time Machine等で外付けHDにバックアップを取った場合にバックアップ終了後、外付けHDを取り外してもエラーになって外付けHDが外せない場合の対処方法ですが、umountコ ...
lftpを使用して自動同期する

lftpはFTPサイトでファイルやディレクトリをダウンロードできたりアップロードできたりするコマンドです。通常のFTPクライアントではrsyncのように特定のディレクトリ ...