linux命令---常见且冷门系列(2)ls 命令

目录

ls命令

ls -l 的另一面

ls 结果的排序

find 命令  递归搜索软链接文件夹


ls命令

必须要使用的命令,离不了。

ls -l 的另一面

我们一般会使用ls -l 命令,其实多数linux发型版本都内置了一个别名ll 命令,对就是两个小的的L。

因此我们直接敲ll就可以时间ls -l 的操作,是不是很简单高效啊,当然大家也可以自己自定义别名。

如下代码段:

root@kali:~/test# ls -l                    
总用量 8
drwxr-xr-x 3 root root 4096  6月  4 10:18 a
drwxr-xr-x 3 root root 4096  6月  4 10:19 b
lrwxrwxrwx 1 root root   11  6月  4 10:29 linkDir -> /root/test1
-rw-r--r-- 1 root root    0  6月  4 10:19 root.txt
                                                                                     
root@kali:~/test# ll   
总用量 8
drwxr-xr-x 3 root root 4096  6月  4 10:18 a
drwxr-xr-x 3 root root 4096  6月  4 10:19 b
lrwxrwxrwx 1 root root   11  6月  4 10:29 linkDir -> /root/test1
-rw-r--r-- 1 root root    0  6月  4 10:19 root.txt
                                                                                     
root@kali:~/test# alias
diff='diff --color=auto'
egrep='egrep --color=auto'
fgrep='fgrep --color=auto'
grep='grep --color=auto'
history='history 0'
ip='ip --color=auto'
l='ls -CF'
la='ls -A'
ll='ls -l'
ls='ls --color=auto'
which-command=whence
                                                                                     
root@kali:~/test# 

ls 结果的排序

ls 默认是有排序的,默认是文件名排序。如下例子

root@kali:~/test# ll --full-time
总用量 20
-rw-r--r-- 1 root root 15 2022-06-04 14:03:16.163601113 +0800 a1.txt
-rw-r--r-- 1 root root 10 2022-06-04 14:03:05.859904505 +0800 a.txt
-rw-r--r-- 1 root root 19 2022-06-04 14:03:24.995341154 +0800 b.txt
-rw-r--r-- 1 root root  4 2022-06-04 14:03:34.131072338 +0800 c.txt
-rw-r--r-- 1 root root 10 2022-06-04 14:03:41.090867621 +0800 d.txt
                                                                                     
root@kali:~/test# 

根据名字反向排序 -r

root@kali:~/test# ll --full-time -r
总用量 20
-rw-r--r-- 1 root root 10 2022-06-04 14:03:41.090867621 +0800 d.txt
-rw-r--r-- 1 root root  4 2022-06-04 14:03:34.131072338 +0800 c.txt
-rw-r--r-- 1 root root 19 2022-06-04 14:03:24.995341154 +0800 b.txt
-rw-r--r-- 1 root root 10 2022-06-04 14:03:05.859904505 +0800 a.txt
-rw-r--r-- 1 root root 15 2022-06-04 14:03:16.163601113 +0800 a1.txt
                                                                                     
root@kali:~/test# 

根据修改时间、根据文件大小排序 例子如下:

# 按照大小排序 也支持-r
root@kali:~/test# ll --full-time -S
总用量 20
-rw-r--r-- 1 root root 19 2022-06-04 14:03:24.995341154 +0800 b.txt
-rw-r--r-- 1 root root 15 2022-06-04 14:03:16.163601113 +0800 a1.txt
-rw-r--r-- 1 root root 10 2022-06-04 14:03:05.859904505 +0800 a.txt
-rw-r--r-- 1 root root 10 2022-06-04 14:03:41.090867621 +0800 d.txt
-rw-r--r-- 1 root root  4 2022-06-04 14:03:34.131072338 +0800 c.txt
                                                                                     
root@kali:~/test# 
#根据修改时间排序 也支持-r
root@kali:~/test# ll --full-time -t
总用量 20
-rw-r--r-- 1 root root 10 2022-06-04 14:03:41.090867621 +0800 d.txt
-rw-r--r-- 1 root root  4 2022-06-04 14:03:34.131072338 +0800 c.txt
-rw-r--r-- 1 root root 19 2022-06-04 14:03:24.995341154 +0800 b.txt
-rw-r--r-- 1 root root 15 2022-06-04 14:03:16.163601113 +0800 a1.txt
-rw-r--r-- 1 root root 10 2022-06-04 14:03:05.859904505 +0800 a.txt

find 命令  递归搜索软链接文件夹

默认情况下find命令不会递归进入软链接的文件夹来搜索文件的,详见

CSDNhttps://mp.csdn.net/mp_blog/creation/editor/125119223

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值