本次输入法使用: 手心输入法 for Mac 1.0版

测试环境为:Ubuntu 14.14.2 LTS updates

测试时间为:2015年5月28日,感觉死亡将至的夜晚,独自一人坐在一个角落,戴着耳机盖着帽子,穿着衬衫的那一天,外面下着雨,不小不大,不紧不慢,却分外的让人不自然,写到这里放的歌是:苏运莹的《野子》

主要解决了特殊用法(为制定参数,. ,..,*的使用)

-d 检测是否为directory时,如果参数为空,也会被错误的认为目录,这是bash的一个诟病吗?应该吧,不过结合-z选项就可以解决。但是问题的关键是我以为-d是会识别的,其实我高估了-d,[see line 34-36]

 function lz() {
function du_dir() {
echo -e "\033[01;33m$1\033[00m" # $((RANDOM%6+1))
(cd $; ls - >/dev/null | sed -e 's/^/"/' -e 's/$/"/'| xargs du -h -d >/dev/null)
}
function du_file() {
(ls -lha $ | awk '{print $5,$9}')
}
function getpath() { # support . and .. as the special path
cd $
echo `pwd`
}
function usage(){
echo -e " \033[01;37musage:\033[00m le [dir]/[file] ..."
echo " if no arguement is given, 'lz' will print the current working dir"
echo " .(current dir), ..(parent dir), *(metachar) are supported"
echo -e "\n -V/-h for this help page"
echo -e " \n--------------------------------------------------\n lz v0.1 by Ray Lee - March 30, 2015"
echo -e " updates:\n 1.clone 'le' as 'lz', new feature added\n 2.empty parameter doesn't work"
echo -e " ^\n lz v0.2 by Ray Lee - may 28, 2015"
echo -e " updates: \n 1.make the empty arg work, printing the current directory\n 2.-V and -h works\n 3.add comments for code block\n 4.modify the help page"
}
default='.'
args=($@)
if [[ ${#args[@]} -gt ]]; then
## the * meta means all the things in the current directory, length of it is gt 1 when current dir contains
## more than 1 thing, 1 if there is only one thing, le 1 when empty
28 ##
for each in ${args[@]}; do
[ -d $each ] && du_dir `getpath $each` || du_file `getpath $each`
done
elif [ ! -z $ ]; then
## The oddness of the -d option for file test is that it recognises the empty as a directory
34 ## So the -z should be used to make -d solid for empty args.
35 ##
if [ -d $ ]; then # support . and .. as the special path
du_dir `getpath $`
elif [[ $ == '-V' ]]; then
usage
elif [[ $ == '-h' ]]; then
usage
fi
else
du_dir `getpath "."`
fi
}

Results:

Reference:

1. http://www.cnblogs.com/raybiolee/p/4240363.html

lz: linux ls 变种 只显示大小和名称(包括目录)的更多相关文章

  1. hbuilder在android手机里用chrome调试,只显示了设备名称,却没有inspect按钮

    stark 通过“菜单”->“工具”->“检查设备”打开设备检查页面,只显示了设备名称,却没有inspect按钮,要怎么办 1 赞2014-10-09 22:00 ============ ...

  2. [Linux] 终端设置只显示当前目录及终端美化

    1.只显示当前目录 vim ~/.bashrc 找到位置: if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($d ...

  3. php递归遍历目录计算其大小(文件包括目录和普通文件)

    <?php function countdir($path){ $size = 0; //size = 0; 跟 size = null; 怎么结果不一样 $path = rtrim($path ...

  4. 关于虚拟机下centOS版linux系统ifconfig只显示inet6ip,不显示inet4ip的问题

    在linux命令窗口输入ifconfig会显示如下 [root@localhost Desktop]# ifconfig eth0   Link encap:Ethernet  HWaddr 00:0 ...

  5. AD域-让共享目录只显示用户有权限访问的文件夹

    问题: 在AD域中,我们一般都会用到共享,如果有很多部门,我们可能还会按部门.职位配置权限.比如CSD,IT,PA等,但文件夹一多,用户看着就头大,而且用户没权限访问的文件夹误点击进去还会提示无权限访 ...

  6. Linux学习总结(5)——CentOS常用的目录文件操作命令

    CentOS常用的目录文件操作命令 一.路径操作的CentOS常用命令  cd pwd  NO1. 显示当前路径  [root@rehat root]# pwd  NO2. 返回用户主目录  [roo ...

  7. Linux -- ls只显示目录

    ls没有直接显示目录的选项, 不过根据目录和文件显示的差异,可以搭配grep来实现 方法1: ll | grep "^d" 方法2: ls -F | grep$ "/$& ...

  8. Linux显示只显示目录文件

    Linux显示只显示目录文件 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ls -l -d */ drwxr-xr-x 2 root root 4096 1 ...

  9. Linux 只显示目录或者文件方法

    ls 参数 -a 表示显示所有文件,包含隐藏文件-d 表示显示目录自身的属性,而不是目录中的内容-F 选项会在显示目录条目时,在目录后加一个/ 只显示目录 方法一: find . -type d -m ...

随机推荐

  1. 面试&笔试常见题,你了解多少?

    HTML:1.  什么是语义化的HTML?有何意义?为什么要做到语义化?(高频率考题)2.  行内元素和块元素分别有哪些?(高频率)3.  严格模式与混杂模式的区分?如何触发这两种模式?(高频率)4. ...

  2. jQuery判断某个元素是否存在某个样式

    <input type="button" class="new"/> $("input[name=new]").hasClass ...

  3. java 中集合和数组互相转换

    package test; import java.util.Arrays;import java.util.List; /** * Created by Administrator on 2016/ ...

  4. ionic build android 报错分析

  5. java中清空session

    session.removeAttribute("sessionname")是清除SESSION里的某个属性.     session.invalidate()是让SESSION失 ...

  6. [CC]ccHObject

    qCC_db中的ccHObject

  7. javascript实例学习之六—自定义日历控件

    基于之前上篇博客轻量级jquery,tool.js和base.js.自定义开发的base_datePicker插件,效果类似于jquery_ui的datePicker插件 //基于Base.js以及t ...

  8. swift语言实战晋级-1 Swift开发环境的搭建

    想要进行Swift的学习,必须要有个开发环境.简单的说就是装好了Xcode的Mac系统.那么接下来我们就简单了解一下这方面的内容. 1.1 下载Xcode Xcode是苹果公司出的编程工具,类似于微软 ...

  9. SQL 数据库 存储过程 视图

    一.存储过程 1.概述 存储过程是一组编译在单个执行计划中的T-SQL语句 存储过程:就像函数一样的会保存在数据库中(可编程性) 存储过程的优点: 1.允许模块化程序设计 2.允许更快执行如果某操作需 ...

  10. stucts2 基础程序

    参考<Struts2+Hibernate+Spring> index.jsp