Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete a specified file with the shell command

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article Xiaobian introduces in detail for you "how to delete the specified file with the shell command", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to delete the specified file with the shell command" can help you solve your doubts.

#! / bin/bashls-li | tail-n + 2 | cat-nread-p "Please enter the line to be deleted:" numinum= `ls-li | tail-n + 2 | cat-n | awk-F'$1 please find'{print $2} '`find. /-inum $inum-exec rm-rf {}\

Run the script and enter the line number to delete the specified line, which can be used to delete some files whose file names are garbled. The operation interface is shown below:

The PS:Shell script deletes the specified file dir=/Users/sanyolewis/Desktop/Android/Demo/app/src/main/res/drawable str= "imageset" for file in $dir/*; do# under the folder to get all the file names under the folder newfile=$ {file#*.} # print file name # echo $newfile # determine string equivalence if ["$newfile" = "$str"] Then rm-rf $file fidone read here, this article "how to use the shell command to delete the specified file" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report