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) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接 ...
随机推荐
- spring中获取applicationContext(2)
前几天写web项目的时候,用到了spring mvc. 但是又写bean.我要在代码里面生成,而这个bean里面,又有一些属性是通过spring注入的. 所以,只能通过ApplicationConte ...
- UUID生成随机数工具类
package com.qiyuan.util; import java.util.UUID; public class RanNum { /** * 生成随机数<br> * GUID: ...
- WPF备忘录(7)WPF图片资源路径介绍
在项目中增加两张图片Content.jpg和Resource.jpg,分别将其生成操作属性设置为Content和Resource. 在界面中增加两个Image控件ImgContent和ImgR ...
- elasticsearch环境搭建
学习elasticsearch有一段时间了,整理一些学习的笔记以备忘. 以下内容都是在windows环境下的操作. 一,安装一个较新版本的java,我本地安装的java 8. 二,安装elastics ...
- js,需要更多源字符
里面有的括号没写完 没有关闭 使整个js都不能用 vs2010安装个下面JS插件,更好的分层, https://marketplace.visualstudio.com/items?itemNam ...
- .net core 2.2 部署CentOS7(5)部署.net core mvc
目录: .net core 2.2 部署CentOS7(1)安装虚拟机 .net core 2.2 部署CentOS7(2)给虚拟机安装CentOS7 .net core 2.2 部署CentOS7( ...
- 十九、curator recipes之PathChildrenCache
简介 curator可以监听路径下子节点的变更操作,如创建节点,删除节点 官方文档:http://curator.apache.org/curator-recipes/path-cache.html ...
- OracleServer总结进阶之系统分析(进阶完结)
个人原创,转载请在文章头部明显位置注明出处:https://www.cnblogs.com/sunshine5683/p/10080102.html 在上一篇进阶中大概讲解了一些关于进阶方面的知识,今 ...
- NGINX防御CC攻击教程
CC攻击即http flood,以攻击成本低(只需数台http代理服务器即可实现攻击).隐蔽性强(中小CC攻击一般不会造成网络瓶颈).难防御(与正常访问的请求很难区分开).威力强大(造成和DDOS流量 ...
- (利用DOM)在新打开的页面点击关闭当前浏览器窗口
1.在开发过程中我们前端的用户体验中有时候会要求点击一个按钮,关闭当前浏览器窗口.用html DOM就可做到. 2.注意:本次写法要求在新窗口中关闭. target="_blank" ...