Questions tagged «ls»

ls命令列出目录的内容。

9
如何仅在ls -Al中输出文件名(带空格)?
我应该只用这种结构回显文件或目录的名称: ls -Al | while read string do ... done ls -Al 输出: drwxr-xr-x 12 s162103 studs 12 march 28 12:49 personal domain drwxr-xr-x 2 s162103 studs 3 march 28 22:32 public_html drwxr-xr-x 7 s162103 studs 8 march 28 13:59 WebApplication1 例如,如果我尝试: ls -Al | while read string do echo …
78 linux  command-line  ls 

11
递归地根据大小排序文件
我需要在文件夹中找到最大的文件。 如何递归扫描文件夹并按大小对内容排序? 我尝试使用ls -R -S,但这也列出了目录。 我也尝试使用find。
78 command-line  find  ls 

2
如何将命令的输出分配给shell变量?
我想将表达式的结果分配给变量并将其与字符串连接,然后回显它。这是我得到的: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 "Screen Shot"; echo "Most recent screenshot is: "$thefile; 但是输出: Screen Shot 2011-07-03 at 1.55.43 PM.png Most recent screenshot is: 因此,它似乎没有分配给$thefile,而是在执行时被打印。


10
在目录列表中显示文件大小总和
Windows dir目录列表命令的末尾有一行,显示列出的文件占用的空间总量。例如,dir *.exe显示.exe当前目录中的所有文件,文件大小以及文件大小的总和。我希望dir在bash中使用别名具有类似的功能,但是我不确定该怎么做。 目前,我有alias dir='ls -FaGl'我的.bash_profile,显示 drwxr-x---+ 24 mattdmo 4096 Mar 14 16:35 ./ drwxr-x--x. 256 root 12288 Apr 8 21:29 ../ -rw------- 1 mattdmo 13795 Apr 4 17:52 .bash_history -rw-r--r-- 1 mattdmo 18 May 10 2012 .bash_logout -rw-r--r-- 1 mattdmo 395 Dec 9 17:33 .bash_profile -rw-r--r-- 1 mattdmo 176 …
71 bash  shell-script  awk  ls 


4
ls命令不适用于包含大量文件的目录
我的目录有大约500万个文件。当我尝试ls从此目录中运行命令时,系统消耗了大量内存,并且一段时间后挂起。除了使用ls命令以外,是否有一种有效的方法来列出文件?
70 ls 

5
了解UNIX权限和文件类型
chmod直到今天,我才真正了解到如何解决问题。我遵循了向我解释了很多事情的教程。 例如,我读到您有三个不同的权限组: 拥有者(u) 组(g) 所有人(o) 基于这三个组,我现在知道: 如果该文件归用户所有,则用户权限确定访问权限。 如果文件的组与用户的组相同,则组权限确定访问权限。 如果用户不是文件所有者,也不在组中,则使用其他权限。 我还了解到您具有以下权限: 阅读(r) 写(w) 执行(x) 我创建了一个目录来测试我新获得的知识: mkdir test 然后我做了一些测试: chmod u+rwx test/ # drwx------ chmod g+rx test/ # drwxr-x--- chmod u-x test/ # drw-r-x--- 经过一段时间的闲逛,我想我终于掌握chmod了使用此命令设置权限的方法。 但... 我还有几个问题: 什么是d在开始代表什么? 包含插槽的名称和用途是什么,它还可以容纳其他哪些值? 如何设置和取消设置? 这有什么价值d?(因为您只有7 = 4 + 2 + 1 7 = 4 + 2 …
68 linux  permissions  ls  chmod 

4
ls -la中的“ s”和“ S”有什么区别?
当我ls -la,它打印许多属性。像这样: -rwSrwSr-- 1 www-data www-data 45 2012-01-04 05:17 README 可耻的是,我不得不承认我不知道每个属性的确切含义。例如,S字符串中big的含义是什么-rwSrwSr--?以下是1什么?我大概认识别人。
67 permissions  ls 



2
ls -F显示的符号是什么意思?
我注意到,如果我在目录上运行ls -F,则某些条目后面会带有*或@。 spuder@ubuntu:~$ ls -F /sbin acpi_available* getpcaps* lvmconf* ntfscp* start-stop-daemon* agetty* getty* lvmdiskscan@ ntfslabel* status@ alsa* halt@ lvmdump* ntfsresize* stop@ alsactl* hdparm* lvmsadc@ spuder@ubuntu:~$ ls -F ~ daq-0.6.1/ examples.desktop noname-cache.lib snort-2.9.1/ Templates/ Desktop/ jpgraph-1.27.1/ noname.sch snortfiles/ Ubuntu One/ Documents/ 根据ls手册页 spuder@ubuntu:~$ man ls ... -F, --classify append indicator (one …
61 ls 

6
ls -l和ll之间的区别?
我对整体编程还是比较陌生,一些教程告诉我使用它ls -l来查看目录中的文件,而其他则一直在说ll。我知道这ls是一个简短的列表,但是其他两个之间有区别吗?
59 shell  shell-script  ls 

4
仅列出n级深的子目录
Festival将语音包数据存储在以下示例目录结构中: /usr/share/festival/voices/<language>/<voicepack name> 在所有潜在的众多子目录中,最简单的单行ls打印(最好使用)打印出来的是什么?<voicepack name><language>
58 bash  ls 

7
如何将不区分大小写的模式与ls匹配?
我想列出所有匹配特定模式的文件,而忽略大小写。 例如,我运行以下命令: ls *abc* 我想查看所有以“ abc”作为文件名一部分的文件,忽略大小写,例如 -rw-r--r-- 1 mtk mtk 0 Sep 21 08:12 file1abc.txt -rw-r--r-- 1 mtk mtk 0 Sep 21 08:12 file2ABC.txt 注意 我已经在手册页中搜索了案例,但是找不到任何东西。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.