当前位置:网站首页>文件系统中的目录与切换操作
文件系统中的目录与切换操作
2022-07-03 09:01:00 【科技那些事儿】
cd
cd,change directory,切换当前工作目录。
除指定目录外,还有以下特殊目录。
.: 当前工作目录。..: 父级工作目录。/: 根目录。~: home 目录,即当前的用户目录,同时也可用环境变量$HOME表示。假设当前用户为 shanyue,则 ~ 目录为/Users/shanyue(mac系统)。
另外,cd - 为进入上一次的工作目录,如同 git checout - 切回上次的分支一样。
$ cd ~
$ cd -
$ cd $HOME
除 cd 外,有一个拥有强大功能切换目录的小工具 autojump。
autojump 需要进行手动下载。
# 切换至含有 foo 子字符串的某个目录
$ j foo
Q: 你知道 autojump 原理吗,你可以写出来一个
autojump命令行小工具吗?
pwd
pwd,print working directory,打印当前工作目录。
# 打印当前路径,该目录为 react 源码内容
$ pwd
/Users/shanyue/Documents/react
ls
ls,列出某个工作目录的内容。
ls 单指令不会列出以 . 开头的文件,比如 .git、 .babelrc、.eslintrc 均不会默认显示。而使用 -a,将会把所有文件列出。
在日常工作中,常使用 ls -lah 列出工作目录内容。
# -l: 使用长列表格式
# -a: 列出所有文件,包括以 . 开头的文件
# -h: 以可读的形式表示文件体积,比如 100M
$ ls -lah
total 2176
drwxr-xr-x 36 shanyue shanyue 1.1K 6 10 15:45 .
[email protected] 242 shanyue shanyue 7.6K 5 29 09:37 ..
drwxr-xr-x 3 shanyue shanyue 96B 6 10 15:45 .circleci
drwxr-xr-x 3 shanyue shanyue 96B 6 10 15:45 .codesandbox
-rw-r--r-- 1 shanyue shanyue 294B 5 22 2021 .editorconfig
-rw-r--r-- 1 shanyue shanyue 759B 6 10 15:45 .eslintignore
-rw-r--r-- 1 shanyue shanyue 8.4K 6 10 15:45 .eslintrc.js
drwxr-xr-x 14 shanyue shanyue 448B 6 10 15:45 .git
-rw-r--r-- 1 shanyue shanyue 12B 5 22 2021 .gitattributes
drwxr-xr-x 6 shanyue shanyue 192B 9 8 2021 .github
-rw-r--r-- 1 shanyue shanyue 881B 6 10 15:45 .gitignore
-rw-r--r-- 1 shanyue shanyue 7.6K 5 22 2021 .mailmap
-rw-r--r-- 1 shanyue shanyue 9B 6 10 15:45 .nvmrc
-rw-r--r-- 1 shanyue shanyue 546B 6 10 15:45 .prettierignore
-rw-r--r-- 1 shanyue shanyue 363B 5 22 2021 .prettierrc.js
-rw-r--r-- 1 shanyue shanyue 3B 5 22 2021 .watchmanconfig
-rw-r--r-- 1 shanyue shanyue 42K 5 22 2021 AUTHORS
-rw-r--r-- 1 shanyue shanyue 198K 6 10 15:45 CHANGELOG.md
-rw-r--r-- 1 shanyue shanyue 3.5K 5 22 2021 CODE_OF_CONDUCT.md
-rw-r--r-- 1 shanyue shanyue 216B 5 22 2021 CONTRIBUTING.md
-rw-r--r-- 1 shanyue shanyue 1.1K 5 22 2021 LICENSE
-rw-r--r-- 1 shanyue shanyue 5.1K 6 10 15:45 README.md
-rw-r--r-- 1 shanyue shanyue 1.5K 6 10 15:45 ReactVersions.js
-rw-r--r-- 1 shanyue shanyue 400B 5 22 2021 SECURITY.md
-rw-r--r-- 1 shanyue shanyue 671B 9 2 2021 appveyor.yml
-rw-r--r-- 1 shanyue shanyue 1.0K 5 22 2021 babel.config.js
drwxr-xr-x 6 shanyue shanyue 192B 9 4 2021 build
drwxr-xr-x 2 shanyue shanyue 64B 9 4 2021 build2
-rw-r--r-- 1 shanyue shanyue 7.5K 6 10 15:45 dangerfile.js
drwxr-xr-x 23 shanyue shanyue 736B 6 10 15:45 fixtures
-rw-r--r-- 1 shanyue shanyue 220B 5 22 2021 netlify.toml
drwxr-xr-x 1426 shanyue shanyue 45K 9 2 2021 node_modules
-rw-r--r-- 1 shanyue shanyue 7.2K 6 10 15:45 package.json
drwxr-xr-x 39 shanyue shanyue 1.2K 6 10 15:45 packages
drwxr-xr-x 22 shanyue shanyue 704B 9 2 2021 scripts
-rw-r--r-- 1 shanyue shanyue 733K 6 10 15:45 yarn.lock
那在 ls 每一行都代表什么信息?在下一节内容讲述。
Q: 如何配置颜色区分目录和文件呢,见下截图。
exa
一个 ls 的替代品,拥有更友好的色彩更丰富的输出,同时支持更丰富的选项。
# 支持查看 git 情况
$ exa -lah --git

tree
tree,以树状图的形式列出文件。
该命令需要手动下载。
# macos
$ brew install tree
# centos
$ yum install tree
可通过 -L 指定层级,平常工作可使用以下指令。
# -a: 列出所有文件
# -F: 对目录末尾添加 /,对可执行文件末尾添加 *
# -L: 指定层级
$ tree packages/react-dom -aF -L 2
packages/react-dom
|-- README.md
|-- client.js
|-- index.classic.fb.js
|-- index.experimental.js
|-- index.js
|-- index.modern.fb.js
|-- index.stable.js
|-- npm/
| |-- client.js
| |-- index.js
| |-- profiling.js
| |-- server.browser.js
| |-- server.js
| |-- server.node.js
| |-- test-utils.js
| `-- unstable_testing.js
|-- package.json
|-- server.browser.js
|-- server.js
|-- server.node.js
|-- src/
| |-- __tests__/
| |-- client/
| |-- events/
| |-- server/
| |-- shared/
| `-- test-utils/
|-- test-utils.js
|-- unstable_testing.classic.fb.js
|-- unstable_testing.experimental.js
|-- unstable_testing.js
|-- unstable_testing.modern.fb.js
`-- unstable_testing.stable.js
8 directories, 25 files
同时,也可以使用更高级的 exa -T 打印树状文件。
# -T: --tree,以树状图的形式列出文件
# -L: --level,指定层级
$ exa -lah -T -L 2 packages/react-dom

边栏推荐
- 2022-2-14 learning xiangniuke project - generate verification code
- [set theory] order relation (chain | anti chain | chain and anti chain example | chain and anti chain theorem | chain and anti chain inference | good order relation)
- The less successful implementation and lessons of RESNET
- Crawler career from scratch (IV): climb the bullet curtain of station B through API
- Run flash demo on ECS
- Numerical analysis notes (I): equation root
- [point cloud processing paper crazy reading cutting-edge version 12] - adaptive graph revolution for point cloud analysis
- [graduation season | advanced technology Er] another graduation season, I change my career as soon as I graduate, from animal science to programmer. Programmers have something to say in 10 years
- Problems in the implementation of lenet
- 【点云处理之论文狂读经典版7】—— Dynamic Edge-Conditioned Filters in Convolutional Neural Networks on Graphs
猜你喜欢

Trial of the combination of RDS and crawler

Django operates Excel files through openpyxl to import data into the database in batches.

【点云处理之论文狂读前沿版9】—Advanced Feature Learning on Point Clouds using Multi-resolution Features and Learni

Utilisation de hudi dans idea

LeetCode每日一题(2090. K Radius Subarray Averages)

2022-2-13 learn the imitation Niuke project - Project debugging skills

IDEA 中使用 Hudi

Hudi 快速体验使用(含操作详细步骤及截图)

Digital statistics DP acwing 338 Counting problem
![[point cloud processing paper crazy reading frontier version 11] - unsupervised point cloud pre training via occlusion completion](/img/76/b92fe4549cacba15c113993a07abb8.png)
[point cloud processing paper crazy reading frontier version 11] - unsupervised point cloud pre training via occlusion completion
随机推荐
LeetCode每日一题(1300. Sum of Mutated Array Closest to Target)
【点云处理之论文狂读经典版8】—— O-CNN: Octree-based Convolutional Neural Networks for 3D Shape Analysis
2022-1-6 Niuke net brush sword finger offer
Detailed steps of windows installation redis
Overview of database system
2022-2-13 learn the imitation Niuke project - Project debugging skills
2022-2-14 learning xiangniuke project - Session Management
Vs2019 configuration opencv3 detailed graphic tutorial and implementation of test code
【点云处理之论文狂读前沿版9】—Advanced Feature Learning on Point Clouds using Multi-resolution Features and Learni
【点云处理之论文狂读前沿版12】—— Adaptive Graph Convolution for Point Cloud Analysis
2022-2-14 learning the imitation Niuke project - send email
Serializer rewrite: update and create methods
Hudi learning notes (III) analysis of core concepts
There is no open in default browser option in the right click of the vscade editor
2022-2-14 learning xiangniuke project - generate verification code
Windows安装Redis详细步骤
Data mining 2021-4-27 class notes
Numerical analysis notes (I): equation root
Introduction to the basic application and skills of QT
Flask+supervisor installation realizes background process resident
