使用shell脚本查看文件类型
显示文件类型
#如查看 /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脚本查看文件类型的更多相关文章
- shell脚本判断文件类型
转自:http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html 1. shell判断文件,目录是否存在或者具有权限 2. #!/bi ...
- Shell脚本查看linux系统性能瓶颈(转)
Shell脚本查看linux系统性能瓶颈(转自:http://blog.51cto.com/lizhenliang/1687612) [root@test ~]# cat show_sys_info. ...
- shell脚本中文件测试
shell脚本中文件测试 author:headsen chen 2017-10-17 14:35:19 个人原创,转载请注明作者,否则 依法追究法律责任 [ -f filename ] ...
- Shell脚本统计文件行数
Shell脚本统计文件行数 转自 http://www.jb51.net/article/61943.htm 示例:row_count.sh文件 awk '{print NR}' row_cou ...
- (转)shell脚本之文件测试操作符及整数比较符
shell脚本之文件测试操作符及整数比较符 原文:http://www.cnblogs.com/Steward-Xu/p/6722592.html 一.文件测试操作符: 在书写测试表达式是,可以使用一 ...
- shell 脚本大文件处理
shell 脚本大文件处理 字符串处理 s='{"_id":{"$oid":"59b73d80930c17474f9f050d"},&qu ...
- linux中的文件类型以及查看文件类型的方法
Linux文件类型和文件的文件名所代表的意义是两个不同的概念,在linux中文件类型与文件扩展名没有关系.它不像Windows那样是依靠文件后缀名来区分文件类型的,在linux中文件名只是为了方便操作 ...
- Azkaban实战,Command类型单一job示例,任务中执行外部shell脚本,Command类型多job工作flow,HDFS操作任务,MapReduce任务,HIVE任务
本文转载自:https://blog.csdn.net/tototuzuoquan/article/details/73251616 1.Azkaban实战 Azkaba内置的任务类型支持comman ...
- shell脚本编程测试类型下
一bash的数值测试 -v VAR变量VAR是否设置 数值测试:-gt 是否大于greater-ge 是否大于等于-eq 是否等于-ne 是否不等于 not equal-lt 是否小于-le 是否小 ...
随机推荐
- jquery 找到指定父级指定子集
其中 closest() : jquery 1.3 新增 从元素本身开始,逐级向上级元素匹配,并返回最先匹配的元素. 其中 find() : 搜索所有与指定表达式匹配的元素.这个函数是找出正在处理的元 ...
- 全局配置一个ajax的错误监控
全局配置一个ajax的错误监控,比如$(document).ajaxError(function(evt, req, settings){ if(req && (req.stat ...
- activiti7删除流程定义的相关信息
package com.zcc.activiti02; import org.activiti.engine.ProcessEngine;import org.activiti.engine.Proc ...
- c++计算1到100以内的质数
自考c++实践的时候,有个求计算1-100的质数的问题,没搞出来 由于考试使用的是Dev-C++开发工具,为了下次考试做准备,改用该工具,直接下载安装即可,不会涉及到什么破解等 下载地址:https: ...
- 如何深入理解Java泛型
一.泛型的作用与定义 1.1泛型的作用 使用泛型能写出更加灵活通用的代码泛型的设计主要参照了C++的模板,旨在能让人写出更加通用化,更加灵活的代码.模板/泛型代码,就好像做雕塑时的模板,有了模板,需要 ...
- python获取网页源代码
最简单的网页取源(不用模拟浏览器的情况) import requests def getHTML(url): try: r = requests.get(url,timeout=30) r.raise ...
- ORA-01400: cannot insert NULL into
Error text: ORA-01400: cannot insert NULL into when insert into view, NULL value handler in trigger. ...
- MATLAB GUI 设计要点 转
https://www.cnblogs.com/wangh0802PositiveANDupward/p/4588512.html 从简单的例子说起吧. 创建Matlab GUI界面通常有两种方式: ...
- PHP构建一句话木马
构建一句话木马,密码为simple: url/search.php?searchtype=5&tid=&area=eval($_POST[simple]) 之后使用菜刀进行链接,密码为 ...
- springboot输出hello world,3种方式(String,JSON,jsp),IDEA开发工具
新建项目: File -> new -> Project -> Spring Initializr -> Next -> Next -> Next-> Pro ...