fileName="/etc/hosts" mfs=$(du --apparent-size --block-size=1 "$fileName" | awk '{ print $1}') echo "$fileName size = ${mfs}" 4、使用find命令获取文件大小 find命令的语法如下: find "/etc/passwd" -printf "%s" find "/etc/passwd" -printf "%s\n" fileName="/etc/hosts" mysi...
find [options] [-D debugopts] [-Olevel] [path] [expression] [options]: -P: 不查找符号链接文件,缺省选项 -L:查找符号链接文件 -H:不查找符号链接,如果查找到的文件不作为expression的参数 -D debugopts: 用于打印诊断信息,用于诊断find查不到你想到的结果 debugopts: tree: Show the expression tree ...
服务器的开发和管理离不开 Bash 脚本,掌握它需要学习大量的细节。 set命令是 Bash 脚本的重要环节,却...
find~-type f-mtime+30-mtime-60# 找出/etc 目录下,一小时以内变更过的文件 find/etc-type f-cmin-60# 找出/etc 目录下,一小时以内访问过的文件 find/etc-type f-amin-60# 找出你账号主目录下,大小是50MB的所有文件 find~-type f-size 50MB # 找出你账号主目录下,大于50MB小于100MB的所有文件 find...
(stat -c %s "$item")echo -n "File: $item, Size: $file_size bytes"elif [ -d "$item" ]; then# 如果是目录,显示目录名和目录中的文件数目num_files=$(find "$item" -maxdepth 1 -type f | wc -l)echo -n "Directory: $item, Files: $num_files"fi# 显示权限信息和最后修改时间...
find命令的使用 find . -size 6c -print 查找6个字节文件 find . -size -32 -print 查找小于32字节的文件、 find . -name 'del.txt' -ok rm {} \; 删除del.txt 删除前并提示 find . -name 'aa.txt' -exec cp {}{,.bak} \;查找aa.txt 并且cp一份名字为aa.txt.bak find . -name 'aa.tx...
3.文件操作命令:touch,file,cp,rm,mv,which,find,ln 4.文件内容操作命令:cat,more,less,head,less,wc,grep 4.归档及压缩命令:gzip,bzip2,tar 四、Bash的常用功能 1.Bash的命令历史 ...
find /home -name .bashrc &> list #使用标准输入的方式创建文件写入数据 cat > catfile #使用标准输入重定向的方式创建文件写入数据 cat > catfile < ~/.bashrc #将.bashrc的输入写入到catfile中 #<<表示结束输入 cat > catfile << "eof"#这是基于标准输入创建文件并写入数据,当输入结束时在最后使用单独...
pi@raspberrypi:~ $ find ./ -type d -name wahaha ./shell_script/wahaha pi@raspberrypi:~ $ 这时候需要再添加 -name 指定名称参数对查找到的文件自定义操作 pi@raspberrypi:~ $ find ./ -name "nohup*" -and -type f -size +1c -exec ls -l '{}' ';' -rw--- 1 pi pi 12 Aug 23 1...
1 bash script to check if a file exists over a certain size 0 Bash if file sizes are greater than 1kb 0 find the difference between two file sizes and compare in an if statement - Bash 1 How to check if the size of a file or a directory is larger than a va...