当前位置:网站首页>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边栏推荐
- 2022-2028 global sound insulation coating industry research and trend analysis report
- Yyds dry inventory difference between bazel and gradle tools
- Bluetooth solution | Lenz technology Amazon direct connected magic lantern solution
- Pytoch Learning Series: Introduction
- FPGA (VIII) RTL code IV (basic circuit design 1)
- Connect error: no route to host (errno:113)
- Is the account opening of GF Securities really safe and reliable
- 层次分析法(AHP)
- The method of displaying or closing the network flying line in Allegro design
- Allegro's method of setting network flying line and network color
猜你喜欢

PWN attack and defense world guess_ num

2022-2028 global bubble CPAP system industry survey and trend analysis report
![Jerry's watch obtains alarm mode settings [chapter]](/img/43/987d864ec6038b10138ce50bcbdf12.jpg)
Jerry's watch obtains alarm mode settings [chapter]

Problème - Ajouter shellerror: permissions d'instrumentation pour le périphérique: vérifier les règles udev.

LeetCode 每日一题——324. 摆动排序 II

In the name of love, fresh e-commerce companies rush to sell flowers on Valentine's Day

mgalcu-a509
![[線性代數] 1.1 二階與三階行列式](/img/ea/70b59c64d3287a887e371a9181fe45.png)
[線性代數] 1.1 二階與三階行列式

2022-2028 global long wave infrared camera and camera core industry research and trend analysis report

STM32L4系列单片机ADC通过内部参考电压精确计算输入电压
随机推荐
PWN攻防世界Level2
ArrayList basic operation and add element source code
Synchronous movement state of Jerry's watch [chapter]
18. `bs对象.节点名.next_sibling` 获取兄弟节点
There's a mystery behind the little login
Counter analysis of the parameter anti content in the backstage of the # yyds dry goods inventory # knife fight shop
2022-2028 global sound insulation coating industry research and trend analysis report
Leetcode counts the logarithm of points that cannot reach each other in an undirected graph
归并排序
深入解析 Apache BookKeeper 系列:第三篇——读取原理
priority_ Understanding of queue
Applet view creation
[issue 259] uncover how count is executed in MySQL?
PWN新手入门Level0
Concise words tell about technical people who must master basic IT knowledge and skills. Part 1
2022-2028 global bubble CPAP system industry survey and trend analysis report
FPGA(七)RTL代码之三(复杂电路设计2)
LinkedList learning
Map and set use pari as the key value. How to define
今日直播|Apache Pulsar x KubeSphere 在线 Meetup 火热来袭