0
0

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.

テキストファイルをバックアップ

Last updated at Posted at 2018-03-27

httpd.confを編集する前にコピーして取っておきたいと思い、バックアップコマンドを書いてみました。

~/bin/orgbackup
#!/bin/sh

if [ -f $1 ]; then
cp -p --backup=numbered $1{,.org}
touch $1.org -r $1
fi

実行権
chmod 755 ~/bin/orgbackup

orgbackup httpd.conf
実行結果
1度目
httpd.conf httpd.conf.org
2度目
httpd.conf httpd.conf.org httpd.conf.org.~1~
3度目
httpd.conf httpd.conf.org httpd.conf.org.~1~ httpd.conf.org.~2~

コピーする前にhttpd.conf.orgが存在したら、httpd.conf.orgがhttpd.conf.org.~3~という最後の番号の次に名前が変更されます。
そして、httpd.confがhttpd.conf.orgにコピーされます。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?