Linux file命令详解
2023-09-11 14:20:11 时间
file: 查看文件类型
file常见命令参数
Usage: file [OPTION...] [FILE...] Determine type of FILEs. --help display this help and exit -v, --version output version information and exit -m, --magic-file LIST use LIST as a colon-separated list of magic number files -z, --uncompress try to look inside compressed files -b, --brief do not prepend filenames to output lines -c, --checking-printout print the parsed form of the magic file, use in conjunction with -m to debug a new magic file before installing it -e, --exclude TEST exclude TEST from the list of test to be performed for file. Valid tests are: ascii, apptype, compress, elf, soft, tar, tokens, troff -f, --files-from FILE read the filenames to be examined from FILE -F, --separator STRING use string as separator instead of `:' -i, --mime output MIME type strings (--mime-type and --mime-encoding) --apple output the Apple CREATOR/TYPE --mime-type output the MIME type --mime-encoding output the MIME encoding -k, --keep-going don't stop at the first match -L, --dereference follow symlinks (default) -h, --no-dereference don't follow symlinks -n, --no-buffer do not buffer output -N, --no-pad do not pad output -0, --print0 terminate filenames with ASCII NUL -p, --preserve-date preserve access times on files -r, --raw don't translate unprintable chars to \ooo -s, --special-files treat special (block/char devices) files as ordinary ones -C, --compile compile file specified by -m -d, --debug print debugging messages
常用的命令展示
file /var/log/secure* -->显示是二进制文件
file /var/log/lastlog -->显示是data文件 -->不能cat –> 只能last命令查看
shell脚本小工具之万能解压和压缩器
【更多参考】https://blog.csdn.net/u010111874/article/details/51655856
#!/bin/bash #脚本说明 #压缩案例: sh ./ext.sh en /root/a.zip ./test 压缩类型 压缩后的文件名 要压缩的文件或者目录 #解压案例: sh ./ext.sh de ./a.zip 压缩类型 解压的文件名 (默认当前目录) type=$1 #压缩类型,en表示压缩,de表示解压 filename=$2 #文件名 to_filename=$3 #如果是压缩则是选择压缩的文件,解压则是输出的文件路径 ext="${filename##*.}" #获取到文件名的后缀 if [ ! $filename ] then #没有传入参数 echo 'error(100)not file(tar|gz|bz2|zip|rar)' exit 0 fi if [ $type = 'en' ] then #压缩至 #匹配相应的文件 case $ext in 'tar') eval "tar cvf $filename $to_filename" ;; 'gz') eval "tar zcvf $filename $to_filename" ;; 'bz2') eval "tar jcvf $filename $to_filename" ;; 'zip') eval "zip $filename $to_filename" ;; *) #不支持该类型 echo 'error(101)This type is not supported(tar|gz|bz2|zip)' ;; esac else #解压至 #匹配相应的文件 case $ext in 'tar') eval "tar xvf $filename" ;; 'gz') eval "tar zxvf $filename" ;; 'bz2') eval "tar jxvf $filename" ;; 'zip') eval "unzip $filename" ;; *) #不支持该类型 echo 'error(101)This type is not supported(tar|gz|bz2|zip)' ;; esac fi
相关文章
- linux grep命令详解
- Linux命令详解之–chmod命令
- 查询系统负载信息 Linux 命令详解
- linux shell 脚本攻略学习13--file命令详解,diff命令详解
- linux shell 脚本攻略学习16--wc命令详解,tree命令详解
- linux shell 脚本攻略学习11--mkdir和touch命令详解
- linux sudo 命令
- windows环境通过cmd命令到ftp上下载文件到linux服务器
- Linux系统调优详解(七)——网络状态查看命令nethogs
- linux kill命令使用
- linux awk命令使用示例
- linux shell seq命令详解
- L79.linux命令每日一练 -- 第11章 Linux系统管理命令 -- sar和chkconfig
- L68.linux命令每日一练 -- 第十章 Linux网络管理命令 -- ping和traceroute
- L67.linux命令每日一练 -- 第十章 Linux网络管理命令 -- netstat和ss
- L14.linux命令每日一练 -- 第二章 文件和目录操作命令 -- md5sum和chown命令
- 【Linux】linux经常使用基本命令
- Linux date命令的用法
- Linux命令常踩的坑
- Linux 命令详解之sed