Windows / Linux dir 命令
- 1. dir
- 2. `dir *.* > data.txt`
- 3. dir - list directory contents
- References
1. dir
显示目录的文件和子目录的列表。
Microsoft Windows [版本 10.0.18363.900]
(c) 2019 Microsoft Corporation。保留所有权利。C:\Users\cheng>dir驱动器 C 中的卷是 OS卷的序列号是 06C1-1F42C:\Users\cheng 的目录2020/06/14 23:32 <DIR> .
2020/06/14 23:32 <DIR> ..
2020/04/29 14:48 <DIR> .dnx
2020/06/14 23:32 <DIR> 3D Objects
2020/05/02 16:43 <DIR> ansel
2020/06/14 23:32 <DIR> Contacts
2020/06/14 23:32 <DIR> Desktop
2020/06/14 23:32 <DIR> Documents
2020/06/20 23:01 <DIR> Downloads
2020/06/14 23:32 <DIR> Favorites
2020/06/14 23:32 <DIR> Links
2020/06/14 23:32 <DIR> Music
2020/04/28 21:27 <DIR> OneDrive
2020/06/14 23:32 <DIR> Pictures
2020/06/14 23:32 <DIR> Saved Games
2020/06/14 23:32 <DIR> Searches
2020/06/25 11:10 <DIR> Videos0 个文件 0 字节17 个目录 20,302,376,960 可用字节C:\Users\cheng>
C:\Users\cheng>E:E:\>dir驱动器 E 中的卷是 DATA卷的序列号是 8EF7-66A5E:\ 的目录2020/05/12 23:07 <DIR> bookcase
2020/06/02 00:14 <DIR> dataset
2020/05/12 23:31 <DIR> English
2020/05/07 11:53 <DIR> foreverstrong_information
2020/06/05 23:33 <DIR> software
2020/05/31 16:54 <DIR> source_code
2020/05/11 19:43 <DIR> yongqiang_workspace0 个文件 0 字节7 个目录 321,886,306,304 可用字节E:\>
2. dir *.* > data.txt
将当前目录文件列表写入 data.txt。通配符 (? 和 *
),?
表示通配一个字符,*
表示通配任意字符。
Microsoft Windows [版本 10.0.18363.900]
(c) 2019 Microsoft Corporation。保留所有权利。C:\Users\cheng>dir驱动器 C 中的卷是 OS卷的序列号是 06C1-1F42C:\Users\cheng 的目录2020/06/14 23:32 <DIR> .
2020/06/14 23:32 <DIR> ..
2020/04/29 14:48 <DIR> .dnx
2020/06/14 23:32 <DIR> 3D Objects
2020/05/02 16:43 <DIR> ansel
2020/06/14 23:32 <DIR> Contacts
2020/06/14 23:32 <DIR> Desktop
2020/06/14 23:32 <DIR> Documents
2020/06/20 23:01 <DIR> Downloads
2020/06/14 23:32 <DIR> Favorites
2020/06/14 23:32 <DIR> Links
2020/06/14 23:32 <DIR> Music
2020/04/28 21:27 <DIR> OneDrive
2020/06/14 23:32 <DIR> Pictures
2020/06/14 23:32 <DIR> Saved Games
2020/06/14 23:32 <DIR> Searches
2020/06/25 11:10 <DIR> Videos0 个文件 0 字节17 个目录 20,301,967,360 可用字节C:\Users\cheng>
C:\Users\cheng>E:E:\>
E:\>dir驱动器 E 中的卷是 DATA卷的序列号是 8EF7-66A5E:\ 的目录2020/05/12 23:07 <DIR> bookcase
2020/06/02 00:14 <DIR> dataset
2020/05/12 23:31 <DIR> English
2020/05/07 11:53 <DIR> foreverstrong_information
2020/06/05 23:33 <DIR> software
2020/05/31 16:54 <DIR> source_code
2020/05/11 19:43 <DIR> yongqiang_workspace0 个文件 0 字节7 个目录 321,886,306,304 可用字节E:\>
E:\>dir *.* > data.txtE:\>
3. dir - list directory contents
--versionoutput version information and exit-a, --alldo not ignore entries starting with .-A, --almost-alldo not list implied . and ..--authorwith -l, print the author of each file-h, --human-readablewith -l and/or -s, print human readable sizes (e.g., 1K 234M 2G)
(base) yongqiang@yongqiang:~/software$ dir --version
dir (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.Written by Richard M. Stallman and David MacKenzie.
(base) yongqiang@yongqiang:~/software$
(base) yongqiang@yongqiang:~/software$ dir
Miniconda3-latest-Linux-x86_64.sh bazel-4.2.1-installer-linux-x86_64.sh platform-tools platform-tools_r30.0.4-linux.zip
(base) yongqiang@yongqiang:~/software$
(base) yongqiang@yongqiang:~/software$ dir -a
. .. Miniconda3-latest-Linux-x86_64.sh bazel-4.2.1-installer-linux-x86_64.sh platform-tools platform-tools_r30.0.4-linux.zip
(base) yongqiang@yongqiang:~/software$
(base) yongqiang@yongqiang:~/software$ dir -A
Miniconda3-latest-Linux-x86_64.sh bazel-4.2.1-installer-linux-x86_64.sh platform-tools platform-tools_r30.0.4-linux.zip
(base) yongqiang@yongqiang:~/software$
(base) yongqiang@yongqiang:~/software$ dir -l
total 120964
-rwxr-xr-x 1 yongqiang yongqiang 66709754 Jul 22 2021 Miniconda3-latest-Linux-x86_64.sh
-rwxr-xr-x 1 yongqiang yongqiang 47611219 Aug 30 2021 bazel-4.2.1-installer-linux-x86_64.sh
drwxr-xr-x 1 yongqiang yongqiang 512 Apr 30 21:08 platform-tools
-rw-r--r-- 1 yongqiang yongqiang 9542280 Jul 31 2020 platform-tools_r30.0.4-linux.zip
(base) yongqiang@yongqiang:~/software$
(base) yongqiang@yongqiang:~/software$ dir -l -h
total 119M
-rwxr-xr-x 1 yongqiang yongqiang 64M Jul 22 2021 Miniconda3-latest-Linux-x86_64.sh
-rwxr-xr-x 1 yongqiang yongqiang 46M Aug 30 2021 bazel-4.2.1-installer-linux-x86_64.sh
drwxr-xr-x 1 yongqiang yongqiang 512 Apr 30 21:08 platform-tools
-rw-r--r-- 1 yongqiang yongqiang 9.2M Jul 31 2020 platform-tools_r30.0.4-linux.zip
(base) yongqiang@yongqiang:~/software$
References
[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/