使用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 是否小 ...
随机推荐
- docker内的服务无法获取用户真实IP
原文:blog.baohaipeng.top 背景:MySQL数据库和Redis运行在宿主机上(Linux),server运行在docker内,web运行在Nginx内(Nginx运行在docker内 ...
- Android多线程:深入分析 Handler机制源码(二)
前言 在Android开发的多线程应用场景中,Handler机制十分常用 接下来,深入分析 Handler机制的源码,希望加深理解 目录 1. Handler 机制简介 定义一套 Android 消息 ...
- linux - sftp, scp, rz, sz(文件传输命令)
1. sftp Secure Ftp 是一个基于SSH安全协议的文件传输管理工具.由于它是基于SSH的,会在传输过程中对用户的密码.数据等敏感信息进行加密,因此可以有效的防止用户信息在传输的过程中被窃 ...
- windows server 2016 支持多用户远程登录
服务器设置多用户同时远程桌面,可以提高访问效率,避免人多抢登服务器. 1. 首先需要先安装远程桌面服务 配置组策略,运行框输入gpedit.msc,打开计算机配置–>管理模板—>wind ...
- 7、执行 suite 后,result.html 测试报告中,测试结果全部显示为通过原因分析
测试用例中,断言 异常后,必须 raise 抛出异常, 若无raise ,则测试报告中测试结果全部显示为通过. 抛出后,显示实际测试结果,通过/未通过 __author__ = 'Administra ...
- es的日期格式
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/mapping-date-format.html 在es中,默认的时间类型为da ...
- js获取url参数值的几种方式
一.原生js获取URL参数值: 比如当前URL为:http://localhost:8080/#/page2?id=100&name=guanxy <template> <d ...
- 【leetcode】965. Univalued Binary Tree
题目如下: A binary tree is univalued if every node in the tree has the same value. Return true if and on ...
- jq随机生成数字加字母的字符串
html代码: <dl class="row"> <dt class="tit"> <label for="title& ...
- 深入理解Magento – 第十章、十一章(英文原版地址,仅供参考)
深入理解Magento – 第十章 – Magento系统覆盖和升级 http://alanstorm.com/magento_upgrade_rewrite_override 深入理解MAGENTO ...