linux 脚本实例  …

本文介绍了一个实用的Shell脚本,能够帮助用户批量地将指定目录下的文件按类型进行分类,并分别存放在对应类型的文件夹中,有效提升文件管理效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
#
#
#
#
########begin###########
stty erase ^h
read -p "Warning, if the file too much will cause greater burden on the system, and the time will be long, to continue it? (y Continue or Empty the last run cache or else Exit)
choose                   #Please do not change this code
case $choose in
        y|yes|Y|YES)
                echo
                ;;
        r|R)
                echo 
"Please wait"
                rm -rf /result
                
if "$?" -eq 0 ]
                  then
                        echo 
"Mission success"
                
else
                        echo 
"Mission faild"
                fi
                ;;

        *)
                echo 
"Bye~"
                exit
                ;;
esac
read -p "Ok,type the path you want to process
flie                  #Please do not change this code

while [[ 0 -eq 0 ]]; do

if -d $flie ]
  then
                echo 
"Please wait"
                sleep 
2
                ls -alfR $flie |grep -v 
"\/" |grep -v ^"\." |grep "\." |awk -F. '{printf "\n" $NF}' /tmp.tmp
                echo 
"\n"
                echo 
"I found those information"
                cat /tmp.tmp uniq
                
for name in `cat /tmp.tmp`
                do

                mkdir -p /result/$name
                cp `
find $flie -type -name "*.$name"/result/$name 2/dev/null
                done
                
break;
else
                
read -r -p "The path entered for the folder is not valid. Enter valid path.
flie
                continue
fi
done
 echo 
"You can see the file under /result. Each type of file will be placed in single folder."
 echo 
"Now,enjoy it."

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值