Home > 備忘録 > Linux > 世代管理・個数制限( 12 )
ファイルが一瞬で削除されるので、自己責任でお願いします。
[root@server]# cat demo.sh
#!/bin/sh
if test -n "`ls -t /home/user | tail -n+11`";then
rm `ls -t /home/user | tail -n+11`
fi/home/userのファイルを10個に制限し、日付の古い順に削除する
[root@server]# cat demo.sh
#!/bin/sh
if test -n "`ls -r /home/user | tail -n+11`";then
rm `ls -r /home/user | tail -n+11`
fi/home/userのファイルを10個に制限し、降順に削除する
[root@server]# cat demo.sh
#!/bin/sh
if test -n "`ls /home/user | tail -n+11`";then
rm `ls /home/user | tail -n+11`
fi/home/userのファイルを10個に制限し、昇順に削除する
| Your IP Address |
| 216.73.216.111 |