LoginSignup
0
0

More than 5 years have passed since last update.

別のディレクトリで、同じディレクトリ構造の同じ名前のファイルを削除する

Posted at

同じディレクトリ構造でトップのディレクトリ名が異なる場合の、同じ日のログをまとめて削除するシェル。
想定しているのは以下のファイル。これがカレントディレクトリの以下に、[pc名]\LOG[日付名].txt で入っている。
pc1/LOG/2018-01-20.txt
pc2/LOG/2018-01-20.txt

ls -F|grep /| sed "s/$/LOG\/2018-01-20.txt /g" |sed "s/^/rm /g" | sh

ls -F|grep / → ディレクトリの一覧を表示(ファイルは表示しない)
sed "s/$/LOG\/2018-01-20.txt →ディレクトリの後ろに、子ディレクトリとファイル名を追加する
sed "s/^/rm /g" → ディレクトリの前に、コマンドを追加する

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