当前位置:首页 » 网页前端 » 多目录文件脚本
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

多目录文件脚本

发布时间: 2022-10-08 08:36:57

‘壹’ 有没有shell 脚本高手,我一个目录下有很多文件,比如1.a1, 1.a2 , 2.a1 , 2.a2 , 3.a1 , 3.a2.......

#!/bin/bash

ls -1A *.* | awk -F"." 'BEGIN{
extCnt=1
}

{
for(i=1;i<=extCnt;i++) {
if($1 == ext[i]) {
fnm[$1]= fnm[$1] " " $0
next
}
}

ext[extCnt] = $1
fnm[ext[extCnt++]]= $0
}

END{
for (i in ext){
print "mkdir -p " ext[i]
nmb = split(fnm[ext[i]], fnmary, " ")
for(j=1; j<=nmb; j++)
print "cat " fnmary[j] ">>" i "/" i ".txt"
}
}' > tmpsh

. tmpsh

‘贰’ 备份很多文件夹下面的最新文件的bat脚本

x/d/sd:project项目Aackupse:project项目Aackups
x/d/sd:project项目Backupse:project项目Backups

有疑问,请追问。

如果对你有帮助,请采纳!谢谢!

‘叁’ linux中用shell脚本怎么实现将多次目录下的某些指定文件全部移到指定顶层目录

find.-name'*.deb'|xargsmv-t.

‘肆’ 批处理脚本 实现将目录中的多个文件(或文件夹)上传到linux系统

FTP不会用,别的帮你实现,自己加入命令即可。
@echo off
::获取本目录下*.tar.gz的文件。
for /f "delims=" %%a in ('dir /a-d/b *.tar.gz") do (
ftp "%%a"
)
::获取本目录下所有config的文件夹.赋值%%a
for /f "delims=" %%a in ('dir /ad/b/s "config"') do (
::获取所有config文件夹下的所有文件。赋值%%b
for /f "delims=" %%b in ('dir /a-d/b "%%a"\*.*") do (
ftp "%%b"
)
)
echo end...
pause

‘伍’ 如何用shell脚本在一个文件夹中建立三个目录,并在每个目录建立10000个文件

mk_file()
{
num=1
while [ $num -ne 10000 ]
do
touch file_$num
num=`expr $num + 1`
done
}

dirname="dir1 dir2 dir3"
for d in $dirname
do
mkdir $d
cd $d
mk_file
cd ..
done

‘陆’ shell脚本同时复制一个目录下的多个文件到指定目录

#!/bin/sh
dir=$1
time=$2
otdir=$3
tmp=`find
$1
-mtime
+$2
-print`
echo
$tmp
cp
$tmp
$otdir
执行时
要有3个参数指定文件的目录
大于指定的时间
复制到的目录
没写验证部分
参数顺序不要写错

‘柒’ shell脚本同时复制一个目录下的多个文件到指定目录

cp games /“指定文件夹” 好像是这样 很长没完linux也不太记得了

‘捌’ shell脚本,目录a下有多个文件,将目录下所有文件按名称大小顺序(079,080,083..)每隔1min拷贝到b目录

1、创建.sh
#!/bin/sh
for file in 'ls a/';do
cp $file b/
done

2、添加每分钟执行一次的计划任务
*/1 * * * * /opt/.sh