shell查询指定目录下满足前缀为6304-BCUST-的文件,如果有多个,取修改时间最小的,输出文件目录
时间: 2024-03-16 19:44:49 浏览: 22
可以使用以下命令来查询指定目录下满足前缀为6304-BCUST-的文件,如果有多个,取修改时间最小的,输出文件目录:
```shell
ls -tr /path/to/directory/6304-BCUST-* | head -n 1
```
其中,`/path/to/directory/` 是指定的目录路径,`6304-BCUST-*` 是文件名的通配符,`ls -tr` 是按照修改时间逆序输出文件列表,`head -n 1` 是取列表中的第一个文件。
注意:如果要查询目录下的所有子目录,可以添加 `-R` 参数,即 `ls -trR /path/to/directory/6304-BCUST-* | head -n 1`。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)