Linux file命令详解
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 file命令详解的更多相关文章
- 【初级】linux rm 命令详解及使用方法实战
rm:删除命令 前言: windows中的删除命令大家都不陌生,linux中的删除命令和windows中有一个共同特点,那就是危险,前两篇linux mkdir 命令详解及使用方法实战[初级]中我们就 ...
- Linux chmod命令详解
Linux chmod命令详解 chmod----改变一个或多个文件的存取模式(mode) chmod [options] mode files 只能文件属主或特权用户才能使用该功能来改变文件 ...
- 【转发】linux yum命令详解
linux yum命令详解 yum(全 称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理, ...
- linux yum 命令 详解
linux yum命令详解 yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能 ...
- Linux find命令详解
转自Linux find命令详解 一.find 命令格式 1.find命令的一般形式为: find pathname -options [-print -exec -ok ...] 2.find命令的 ...
- Linux cat命令详解
本文主要内容源自网络,参考资料如下: 华夏名网,linux cat命令详解,http://www.sudu.cn/info/html/edu/20070101/290711.html 命令格式:cat ...
- linux tee 命令详解
man tee: NAME tee - read from standard input and write to standard output and files SYNOPSIS tee [OP ...
- linux sar 命令详解(转载)
linux sar 命令详解 2013-04-01 11:05 [小 大] 来源: 开源中国社区 评论: 0 分享至: 百度权重查询 词库网 网站监控 服务器监控 SEO监控 手机游戏 iPhone游 ...
- Linux lsof命令详解和使用示例【转】
所以如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接 ...
随机推荐
- C#中通过Lambda表达式为委托传入更多的参数
如: DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += (o, e) => { d ...
- 打包命令tar
tar是linux下最常用的打包命令,使用tar打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的,也有.gz或.bz2结尾的. 1 常用参数 -c,--create # 新建打 ...
- 破局人工智能:构建AI,与腾讯云一起探索语音应用场景
本文来自腾讯云技术沙龙,本次沙龙主题为AI平台及智能语音应用解析 近年来,人工智能技术快速发展,与其他行业的结合也成为业界不断探索的方向.在人工智能基础和工具方面,AI平台已成为降低人工智能门槛的关键 ...
- spark集群构建
一.spark启动有standalong.yarn.cluster,具体的他们之间的区别这里不在赘述,请参考官网.本文采用的是standalong模式进行搭建及将接使用. 1.首先去官网下载需要的sp ...
- 用imageMagick合成图片添加图片水印
用imageMagick合成图片的方式大致有三种, 使用convert命令加 +append或-append参数 使用convert命令加 -composite参数 直接使用composite命令来完 ...
- [转]Gridview实现多列排序,并显示图标
本文转自:http://blog.csdn.net/gmjinrong/article/details/4516301 GridView实现支持多列排序,并显示升.降序图标上网找了很多资料参考才解决了 ...
- BASE64转文件下载
你可以用HTML 5 注意:返回的文件数据必须是base 64编码的,因为您不能对二进制数据进行JSON编码 在我的AJAX我得到了如下的数据结构: <!DOCTYPE html> < ...
- [HTML5] Canvas绘制简单图片
获取Image对象,new出来 定义Image对象的src属性,参数:图片路径 定义Image对象的onload方法,调用context对象的drawImage()方法,参数:Image对象,x坐标, ...
- 好用的js-cookies工具
背景 回顾一年前的代码,关于cookies这块,增删改查完全可以封装成一个模块.在MDN上看到一款很全的分享,在此做个记录. cookies模块 /*\ |*| |*| :: cookies.js : ...
- php Closure::bind的参数说明
publicstatic Closure Closure::bind ( Closure $closure , object$newthis [, mixed$newscope = 'static' ...