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命令详解的更多相关文章

  1. 【初级】linux rm 命令详解及使用方法实战

    rm:删除命令 前言: windows中的删除命令大家都不陌生,linux中的删除命令和windows中有一个共同特点,那就是危险,前两篇linux mkdir 命令详解及使用方法实战[初级]中我们就 ...

  2. Linux chmod命令详解

    Linux chmod命令详解 chmod----改变一个或多个文件的存取模式(mode)   chmod [options] mode files   只能文件属主或特权用户才能使用该功能来改变文件 ...

  3. 【转发】linux yum命令详解

    linux yum命令详解 yum(全 称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理, ...

  4. linux yum 命令 详解

    linux yum命令详解 yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能 ...

  5. Linux find命令详解

    转自Linux find命令详解 一.find 命令格式 1.find命令的一般形式为: find pathname -options [-print -exec -ok ...] 2.find命令的 ...

  6. Linux cat命令详解

    本文主要内容源自网络,参考资料如下: 华夏名网,linux cat命令详解,http://www.sudu.cn/info/html/edu/20070101/290711.html 命令格式:cat ...

  7. linux tee 命令详解

    man tee: NAME tee - read from standard input and write to standard output and files SYNOPSIS tee [OP ...

  8. linux sar 命令详解(转载)

    linux sar 命令详解 2013-04-01 11:05 [小 大] 来源: 开源中国社区 评论: 0 分享至: 百度权重查询 词库网 网站监控 服务器监控 SEO监控 手机游戏 iPhone游 ...

  9. Linux lsof命令详解和使用示例【转】

    所以如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接 ...

随机推荐

  1. 修改 /etc/pam.d/login, linux 本地账号密码无法登陆,一直返回 登陆的login界面

    今天我在我虚拟机测试的时候遇到了一个问题.登陆centos一直是返回login,账号和密码没错,我也换了两个用户. 1.问题描述 我正常的输入用户名和密码 错误提示截图:返回登陆界面,我重新试了另外的 ...

  2. hadoop学习笔记(五):HDFS Shell命令

    一.HDFS文件命令 以下是比较重要的一些命令: [root@master01 hadoop]# hadoop fs -ls / //查看根目录下的所有文件 [root@master01 hadoop ...

  3. <思考的技术>简记

    1.查看资料及背景,将导出的结论.主张列成一张表:2.把表上的结论.主张根据主题的类似性作分类:3.将同一类型的结论.主张按顺序区分:这个时候,把有因果关系的主张或结论分别放好,原因放在下面,结果放在 ...

  4. RabbitMQ.NET In Window Service

    工作中要求使用RabbitMQ,以Windows Service 模式启动,中间有遇到一些问题,网上大部分博客有误导倾向, 在这里做一个简单的记录,以免后面的人走坑: 1. 自动重新连接,不需要手动处 ...

  5. 使用<% =Type%>获取后台值时报错:控件包含代码块(即 <% ... %>),因此无法修改控件集合。

    <% =Type%>不能放在runat="server"的标签中,删掉runat="server"之后dev的控件回调第一次发生时会刷新页面,有ru ...

  6. eclipse/myEclipse 代码提示和快捷键

    一.设置自动提示 设置eclipse/myEclipse代码提示可以方便开发者,不用在记住拉杂的单词,只用打出首字母,就会出现提示代码菜单. 1.菜单window->Preferences-&g ...

  7. 四:Jquery-animate

    动画效果: 1.显示/隐藏动画效果 动态的改变当前元素的宽,高和不透明度 show([duration],[fn]); //显示当前元素 hide([duration],[fn]); //隐藏当前元素 ...

  8. CentOS 忘记root密码(重置root密码)

    首先开机选择Advanced options for ****这一行按回车: 然后选中最后是(recovery mode)这一行按"E"进入编辑页面: 将ro recovery改为 ...

  9. JavaWeb学习总结(十):Session简单使用

    一.Session简单介绍 在WEB开发中,服务器可以为每个用户浏览器创建一个会话对象(session对象),注意:一个浏览器独占一个session对象(默认情况下).因此,在需要保存用户数据时,服务 ...

  10. Android Studio cannot resolve symbols

    引入了第三方类库,不管怎么编译  clean 都找多到类库 关闭重新打开android studio就好了.....