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. 微服务 + Docker + Kubernetes 入门实践 目录

    微服务 + Docker + Kubernetes 入门实践: 微服务概念 微服务的一些基本概念 环境准备 Ubuntu & Docker 本文主要讲解在 Ubuntu 上安装和配置 Dock ...

  2. js 3行代码,最简易实现div效果悬浮

    简易实现浮动效果的首要因素是:获取滚动条距离浏览器顶部的距离,下面直接贴代码: <!DOCTYPE html> <html> <head> <meta cha ...

  3. c#基础学习(0626)之占位符、转义符

    占位符 使用方法:先挖个坑,再填个坑. 使用占位符需要注意的地方: 1.你挖了几个坑,就应该填几个坑,如果填多了,没效果,如果填少了,出现异常 异常是指:语法上没有任何错误,只不过再运行的期间,由于某 ...

  4. Android 控件:使用下拉列表框--Spinner

    ---恢复内容开始--- 一.前段代码 <Spinner android:id="@+id/spin" android:paddingTop="10px" ...

  5. 读取配置文件-AppConfig

    using System.Xml; using System.IO; using System; namespace Framework.Common { /// <summary> // ...

  6. THINK PHP 学习笔记20171115

    Part1:框架目录project 应用部署目录 ├─application 应用目录(可设置) │ ├─common 公共模块目录(可更改) │ ├─index 模块目录(可更改) │ │ ├─co ...

  7. POJ3414(KB1-H BFS)

    Pots Description You are given two pots, having the volume of A and B liters respectively. The follo ...

  8. php excel原理

  9. css的元素表现

    块级元素和行内元素的表现: 块级元素:块级元素和父元素的宽度一致,默认情况下就是和body的宽度一样,也可以说和浏览器窗口的宽度一致,致使同一行不能再放下另外的元素,所以块级元素表现为独占一行. 块级 ...

  10. css points

    <style type="text/css" rel="stylesheet">.a{ width:500px; height:400px;对放置图 ...