显示文件类型

#如查看   /etc 目录
[root@localhost ~]# sh test.sh /etc
/etc/ [目录文件]
#如查看   /etc 目录下所有文件
[root@localhost ~]# sh test.sh /etc/*
/etc/abrt [目录文件]
/etc/adjtime [普通文件]
/etc/aliases [普通文件]
/etc/aliases.db [普通文件]
/etc/alsa [目录文件]
/etc/alternatives [目录文件]
/etc/anacrontab [普通文件]
............

脚本从这里开始,新建test.sh文件。

#!/bin/bash
for i in $@
do
if [ -L "$i" ];then
printf "\e[36m%-50s[软链接文件]\e[0m\n" "$i" elif [ -f "$i" ];then
printf "\e[37m%-50s[普通文件]\e[0m\n" "$i" elif [ -d "$i" ];then
printf "\e[34m%-50s[目录文件]\e[0m\n" "$i" elif [ -c "$i" ];then
printf "\e[33m%-50s[字符设备文件]\e[0m\n" "$i" elif [ -b "$i" ];then
printf "\e[33m%-50s[设备块文件]\e[0m\n" "$i" elif [ -p "$i" ];then
printf "\e[33m%-50s[管道文件]\e[0m\n" "$i" elif [ -S "$i" ];then
printf "\e[35m%-50s[套接字文件]\e[0m\n" "$i" else
printf "\e[32m%-50s[其他格式文件]\e[0m\n" "$i"
fi
done

使用shell脚本查看文件类型的更多相关文章

  1. shell脚本判断文件类型

    转自:http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html 1. shell判断文件,目录是否存在或者具有权限 2. #!/bi ...

  2. Shell脚本查看linux系统性能瓶颈(转)

    Shell脚本查看linux系统性能瓶颈(转自:http://blog.51cto.com/lizhenliang/1687612) [root@test ~]# cat show_sys_info. ...

  3. shell脚本中文件测试

    shell脚本中文件测试 author:headsen chen  2017-10-17  14:35:19 个人原创,转载请注明作者,否则 依法追究法律责任 [ -f  filename  ]   ...

  4. Shell脚本统计文件行数

    Shell脚本统计文件行数 转自 http://www.jb51.net/article/61943.htm    示例:row_count.sh文件 awk '{print NR}' row_cou ...

  5. (转)shell脚本之文件测试操作符及整数比较符

    shell脚本之文件测试操作符及整数比较符 原文:http://www.cnblogs.com/Steward-Xu/p/6722592.html 一.文件测试操作符: 在书写测试表达式是,可以使用一 ...

  6. shell 脚本大文件处理

    shell  脚本大文件处理 字符串处理 s='{"_id":{"$oid":"59b73d80930c17474f9f050d"},&qu ...

  7. linux中的文件类型以及查看文件类型的方法

    Linux文件类型和文件的文件名所代表的意义是两个不同的概念,在linux中文件类型与文件扩展名没有关系.它不像Windows那样是依靠文件后缀名来区分文件类型的,在linux中文件名只是为了方便操作 ...

  8. Azkaban实战,Command类型单一job示例,任务中执行外部shell脚本,Command类型多job工作flow,HDFS操作任务,MapReduce任务,HIVE任务

    本文转载自:https://blog.csdn.net/tototuzuoquan/article/details/73251616 1.Azkaban实战 Azkaba内置的任务类型支持comman ...

  9. shell脚本编程测试类型下

    一bash的数值测试 -v VAR变量VAR是否设置 数值测试:-gt 是否大于greater-ge 是否大于等于-eq 是否等于-ne 是否不等于  not equal-lt 是否小于-le 是否小 ...

随机推荐

  1. 转 loadrunner11 录制 chrome 浏览器

    chrome不设置代理的原始状态 图1 [LoadRunner]解决LR11无法录制Chrome浏览器脚本问题   LoadRunner录制脚本时,遇到高版本的IE.FireFox,或者Chrome浏 ...

  2. Shell判断某文件夹下是否存在xxx开头的字符串

    Usage: bash judge_prefix_string.sh TARGET_DIR TARGET_STR #!/bin/bash TARGET_DIR=$1 TARGET_STR=$2 ls ...

  3. MUI对话框使用

    一.alert告警框 用法 .alert(message,title,btnvalue,callback[,type]); document.getElementById("noclick& ...

  4. tushare下载安装教程与版本更新步骤

    使用前提 安装Python 安装pandas:pip install pandas 安装lxml:pip install lxml 下载安装 方式1:pip install tushare,如果安装网 ...

  5. 自己写IRP,做文件操作,遇到的坑

    在写文件的时候没问题,但是写完文件之后,就出问题了, 什么问题呢,是因为写完文件之后,文件关闭之后, 调用了一个叫做 CcFlushCache 的函数,这个函数是从CcWriteBehind 调过来的 ...

  6. hbuilder 配置app为沉浸式状态栏

  7. 一键对centos7.6安装python3环境已经pip3

    1 yum -y install "Development tools" 2 yum -y install zlib-devel bzip2-devel openssl-devel ...

  8. leetcood学习笔记-13

    错误记录 class Solution: def romanToInt(self, s: str) -> int: d = {'I':1,'V':5,'X':10,'L':50,'C':100, ...

  9. BZOJ 3328: PYXFIB 解题报告

    BZOJ 3328: PYXFIB 题意 给定\(n,p,k(1\le n\le 10^{18},1\le k\le 20000,1\le p\le 10^9,p \ is \ prime,k|(p- ...

  10. vue基础二

    1.vue实例 每个 Vue.js 应用都是通过构造函数 Vue 创建一个 Vue 的根实例 启动的.在实例化 Vue 时,需要传入一个选项对象,它可以包含数据.模板.挂载元素.方法.生命周期钩子等选 ...