Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次の命名規則を持つファイルのグループが与えられます。
datetime_restofname.txt
その例は次のとおりです。
200906290700_somewordorphrase.txt
ファイル名の日付と時刻に一致するようにファイルのmtimeをバッチ変更するにはどうすればよいですか?
$ for f in *.txt; do touch -t `echo $f | cut -f1 -d _` "$f"; done
これにより、ファイルmodtimeがアンダースコアの前の日付文字列に設定されます。