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 3 years have passed since last update.

inode指定でファイルを削除するシェルスクリプト

Posted at

inode指定でファイルを削除するシェルスクリプト

FTPサーバで、ファイル名がSJISのままPUTされて、普通に削除できくなる場合があります。
対処として、inodeを指定して手作業で削除する方法はよく知られています。

cronで削除するため、シェルスクリプト化してみました。

/dataの配下でhogeユーザがオーナーのファイルのみ削除するサンプルです。
検証はCentOS 8.0で行いました。

delinode.sh
# !/usr/bin/bash
for item in $(ls -i $(find /data -type f -user hoge) | awk '{print $1}') ; do
    find . -inum ${item} -exec rm -rf {} \;
done
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?