当前位置:网站首页>Shell script to count files, then remove oldest files
Shell script to count files, then remove oldest files
2022-06-29 03:13:00 【Rich in starch】
problem :
I am new to shell scripting, so I need some help here. I am a shell New to scripting , So I need some help .I have a directory that fills up with backups. I have a directory full of backups .If I have more than 10 backup files, I would like to remove the oldest files, so that the 10 newest backup files are the only ones that are left. If I have 10 More than backup files , I want to delete the oldest file , So that only 10 The latest backup files .
So far, I know how to count the files, which seems easy enough, but how do I then remove the oldest files, if the count is over 10? up to now , I know how to count files , It seems easy , But if the count exceeds 10, How do I delete the oldest files ?
if [ls /backups | wc -l > 10] then echo "More than 10"fiSolution :
Reference resources : https://stackoom.com/en/question/CQ2I边栏推荐
- allegro设置网络飞线以及网络颜色的方法
- 2022-2028 global bubble CPAP system industry survey and trend analysis report
- Solve the problem that the cursor flashes after clicking a point when measuring the distance in Allegro
- [linear algebra] 1.2 total permutation and commutation
- FPGA (VII) RTL code III (complex circuit design 2)
- [linear algebra] 1.1 second and third order determinants
- ArrayList basic operation and add element source code
- map,set用pari作为key值,如何定义
- 兰宝传感科技冲刺科创板:年营收3.5亿 许永童家族色彩浓厚
- 广发证券开户是真的安全可靠吗
猜你喜欢
![[linear algebra] 1.1 second and third order determinants](/img/ea/70b59c64d3287a887e371a9181fe45.png)
[linear algebra] 1.1 second and third order determinants

mgalcu-a509

Concise words tell about technical people who must master basic IT knowledge and skills. Part 1

There's a mystery behind the little login
![[yunyuanyuan] it's so hot. Why don't you come and understand it?](/img/a8/99037ec5b796e39b9e76eac95deb86.png)
[yunyuanyuan] it's so hot. Why don't you come and understand it?
![Jerry's watch stops moving [chapter]](/img/04/0238701722e1f90410b37385b164e2.jpg)
Jerry's watch stops moving [chapter]

1110: nearest common ancestor (function topic)

Connect error: no route to host (errno:113)

【雲原生】這麼火,你不來了解下?
![[issue 259] uncover how count is executed in MySQL?](/img/bc/ee26eba95f408ea887d6aa06301a0b.jpg)
[issue 259] uncover how count is executed in MySQL?
随机推荐
Problème - Ajouter shellerror: permissions d'instrumentation pour le périphérique: vérifier les règles udev.
PWN attack and defense world level2
Movement state change of monitoring device of Jerry's watch [chapter]
深入解析 Apache BookKeeper 系列:第三篇——读取原理
Concise words tell about technical people who must master basic IT knowledge and skills. Part 1
問題——adb shellerror: insufficient permissions for device: verify udev rules.
[yunyuanyuan] it's so hot. Why don't you come and understand it?
Gartner“客户之声”最高分,用户体验成中国数据库一大突破口
Data discretization
2022-2028 global bubble CPAP system industry survey and trend analysis report
priority_queue的理解
LabVIEW generate application (exe) and installer
PHP database ODBC
What is a thread pool?
If you dare to write MQ message queue middleware on your resume, you must win these questions!
Connect error: no route to host (errno:113)
18. `bs对象.节点名.next_sibling` 获取兄弟节点
[together with Shangshui Shuo series] day 6-strong liver academic paper! The most detailed explanation!
sql训练01
SVN常用的十个命令