当前位置:网站首页>File operation command
File operation command
2022-07-07 12:56:00 【LC181119】
One 、 File operations
1. View the current working directory
- -P Show real physical path
- -L Show link path ( Default )
2. Absolute and relative paths
- Absolute path
- Relative paths
3. Change directory
- Switch to the parent directory : cd ..
- Switch to the current user's home directory : cd
- Switch to the previous working directory : cd -
4. List the contents of the catalog
ls [options] [files_or_dirs]
- -a Contains hidden files
- -l Show additional information
- -R Directory recursion
- -ld Catalog and symlink information
- -1 The document line shows
- -S Sort from big to small
- -t Press mtime Sort
- -u coordination -t Options , Show and press atime Sort from new to old
- -U Display... In the order in which the contents are stored
- -X Sort by file suffix
- -F Attach different symbols when displaying different types of files :*/=>@|
- -C Documents are long , Display files in multiple columns , The default is a column ( standard output )
5. View file status stat
- access time Access time ,atime, Read file contents
- modify time Modification time ,mtime, Change file content ( data )
- change time Change time ,ctime, Metadata changed
6. Determine the contents of the document
file [options] <filename>...
- -b When listing file identification results , Do not show file name
- -f filelist Lists the files filelist The file type of the file name in
- -F Replace the output file name with the specified separator ”:” Separator
- -L View the file type of the corresponding soft link
- --help Display command online help
7. File wildcard pattern wildcard pattern
* Matches zero or more characters , But don't match "." Opening file , That is, hidden files
? Match any single character , A Chinese character is also a character
~ Current user home directory
~mage user mage Home directory
. and ~+ Current working directory
~- Previous working directory
[0-9] Match number range
[a-z] A letter
[A-Z] A letter
[wang] Match any character in the list
[^wang] Match all characters in the list except for
[^a-z] Match all characters in the list except for
[:digit:]: Arbitrary number , amount to 0-9
[:lower:]: Any lowercase letter , Express a-z
[:upper:]: Any capital letter , Express A-Z
[:alpha:]: Any upper and lower case letters
[:alnum:]: Any number or letter
[:blank:]: Horizontal white space characters
[:space:]: Horizontal or vertical white space characters
[:punct:]: Punctuation
[:print:]: Printable characters
[:cntrl:]: control ( unprintable ) character
[:graph:]: Graphic characters
[:xdigit:]: Hexadecimal characters
8. Create empty files and refresh time
touch [OPTION]... FILE...
- -a Just change atime and ctime
- -m Just change mtime and ctime
- -t [[CC]YY]MMDDhhmm[.ss] Appoint atime and mtime The timestamp
- -c If the file doesn't exist , Do not create
9. Copy files and directories
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
- -i If the goal already exists , Prompt whether to cover before covering
- -n No coverage , Pay attention to the order of the two
- -r, -R Recursively copies directories and everything inside
- -a file , amount to -dR --preserv=all, Commonly used for backup functions
- -d --no-dereference --preserv=links Do not copy the original file , Copy only the link name
- --preserv[=ATTR_LIST]
mode: jurisdiction
ownership: Belong to the main genus group
timestamp:
links
xattr
context
all
- -p equivalent --preserv=mode,ownership,timestamp
- -v --verbose
- -f --force
- -u --update Copy only files that the source updates or the destination does not exist
- -b Goals exist , Backup before overwriting , The default form is filename~ , Keep only the most recent backup
10. Move and rename files
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
- -i Interactive
- -f mandatory
- -b Goals exist , Backup before overwriting
rename [options] <expression> <replacement> <file>...
11. Delete file
rm [OPTION]... FILE...
- -i Interactive
- -f Mandatory deletion
- -r recursive
- --no-preserve-root Delete /
shred [OPTION]... FILE...
- -z Last overlay add 0, To hide the override operation
- -v Able to display operation progress
- -u Truncate and delete files after overwriting
- -n # Specify the number of times to overwrite the contents of the file ( The default value is 3 Time )
Two 、 Directory operation
1. Show tree tree
- -d: Show only directories
- -L level: Specify the number of levels to display
- -P pattern: Only display specified by wild-card pattern Match the path to
2. Create directory mkdir
- -p: There is no error reporting , And can automatically create the required directories
- -v: Show details
- -m MODE: When creating a directory, you can directly specify permissions
3. Delete empty directory rmdir
- -p Recursively delete the parent empty directory
- -v Show details
Be careful :rmdir Only empty directories can be deleted , If you want to delete a non empty directory , have access to rm -r command , Delete tree recursively
边栏推荐
- Aike AI frontier promotion (7.7)
- [爬虫]使用selenium时,躲避脚本检测
- Sequoia China completed the new phase of $9billion fund raising
- 博文推荐|Apache Pulsar 跨地域复制方案选型实践
- Find ID value MySQL in string
- 聊聊Redis缓存4种集群方案、及优缺点对比
- [difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
- 2022危险化学品生产单位安全生产管理人员考题及在线模拟考试
- 企业级自定义表单引擎解决方案(十二)--体验代码目录结构
- 【无标题】
猜你喜欢
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
ICLR 2022 | pre training language model based on anti self attention mechanism
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
关于 appium 启动 app 后闪退的问题 - (已解决)
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
[statistical learning method] learning notes - support vector machine (Part 2)
爱可可AI前沿推介(7.7)
[statistical learning methods] learning notes - Chapter 5: Decision Tree
NPM instal reports agent or network problems
Several ways to clear floating
随机推荐
PHP调用纯真IP数据库返回具体地址
3D content generation based on nerf
Multi row and multi column flex layout
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
HZOJ #236. Recursive implementation of combinatorial enumeration
处理链中断后如何继续/子链出错removed from scheduling
[爬虫]使用selenium时,躲避脚本检测
Visual stdio 2017 about the environment configuration of opencv4.1
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
《ASP.NET Core 6框架揭秘》样章[200页/5章]
Cryptography series: detailed explanation of online certificate status protocol OCSP
What if does not match your user account appears when submitting the code?
广州市召开安全生产工作会议
leetcode刷题:二叉树27(删除二叉搜索树中的节点)
Master公式。(用于计算递归的时间复杂度。)
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
测试下摘要
【从 0 开始学微服务】【01】什么是微服务
HZOJ #235. Recursive implementation of exponential enumeration
Leetcode question brushing: binary tree 26 (insertion operation in binary search tree)