LoginSignup
0
0

More than 1 year has passed since last update.

Linuxコマンド備忘録

Posted at

はじめに

  • 備忘録としてLinuxコマンドを書き留めておく。
  • 気になったものがあれば都度追加する。

ファイルのバックアップコピーと反映を1つのコマンドで実行

改善前

# cp -p /app/fileA.sh /app/fileA.sh_20210624 (ファイルのバックアップ)
# cp -f /tmp/fileA.sh /app/fileA.sh (ファイル反映)
# rm -f /tmp/fileA.sh (ファイル削除)

上記と同じことを1つのコマンドで実行できる。

# mv -fb --suffix=_$(date +%Y%m%d) /tmp/fileA.sh /app/fileA.sh
  • オプション説明
    • -f
      • コピー先に同じ名前のファイルがあっても警告なしで上書きする。
    • -b
      • コピー先に同じ名前のファイルがある場合は上書きする前に、上書き前のバックアップファイルを作成する。
    • -S(--suffix)
      • -b(--backup)オプションで作成されるバックアップファイルの名前の後ろにつく文字列を指定することができる。

その他あれば、こちらに都度追加して残しておく

0
0
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
0
0