当前位置:网站首页>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 设计中显示网络飞线或关闭网络飞线的方法
- 认证培训|StreamNative Certification 培训第2期
- [Shangshui Shuo series] the simplest subtitle configuration
- STM32L4系列单片机ADC通过内部参考电压精确计算输入电压
- Yyds dry inventory difference between bazel and gradle tools
- Certification training | streamnational certification training phase 2
- Informatics Olympiad 1361: Produce
- If you dare to write MQ message queue middleware on your resume, you must win these questions!
- Delphi time to timestamp
- Problème - Ajouter shellerror: permissions d'instrumentation pour le périphérique: vérifier les règles udev.
猜你喜欢

2022-2028 global bubble CPAP system industry survey and trend analysis report

图扑软件智慧能源一体化管控平台

初探元宇宙存储,数据存储市场下一个爆点?

How does sound amplify weak sounds

Analytic hierarchy process (AHP)

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

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

Yyds dry inventory everything a primary developer should know about activity

LinkedList学习

FPGA (VII) RTL code III (complex circuit design 2)
随机推荐
Movement state change of monitoring device of Jerry's watch [chapter]
測試入門——集成測試
set time format
SVN常用的十个命令
Yyds dry inventory difference between bazel and gradle tools
Ten commands commonly used in SVN
[North Asia data recovery] data recovery case of ibm-ds3512 storage server RAID5 damaged data loss
The continued movement of Jerry's watch [chapter]
图扑软件智慧能源一体化管控平台
[linear algebra] 1.1 second and third order determinants
FPGA (VII) RTL code III (complex circuit design 2)
What is a thread pool?
PAT甲级 A1057 Stack
Tortoise 没有显示绿色图标
Solve the problem that the cursor flashes after clicking a point when measuring the distance in Allegro
Quick sort, query the k-largest number of the sequence
arraylist基操和添加元素源码
PWN attack and defense world level2
层次分析法(AHP)
归并排序