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?

ディレクトリ丸ごと touchコマンド

Posted at

最初に

touchコマンドとは

簡単に
linuxで使うファイル作成/日付更新コマンド
使い方
touch オプション ファイル名
オプション 内容 備考
-a アクセス日時のみ更新
-c ファイルがないときは作成しない
-d 日時指定 2025-06-30 13:01
-a アクセス日時のみ更新
-r なにかのファイルと日時を合わせる
--help ヘルプ
--version バージョン
困ったこと
ファイル単体でしか使えない

中身を全部更新するシェルスクリプト

シェルスクリプト
#!/bin/bash

if [ $# -eq 2 ]; then
  echo "sudo find $1 | xargs touch -d" "$2"
  find $1 | xargs touch -d "$2"
else
  echo "usage dir_touch.sh [directory] [YYYY-MM-DD hh:mm]"
fi

最後に

コードはCC BY-SA 4.0(著作者の情報とCCライセンス継承はお願いします。商用利用・改変・再配布は問題なし)です。

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?