当前位置:网站首页>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
边栏推荐
- Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion
- SSM框架搭建的步骤
- Several ways to clear floating
- Common knowledge of one-dimensional array and two-dimensional array
- Day-14 common APIs
- HZOJ #240. Graphic printing IV
- Connect to blog method, overload, recursion
- 2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
- Ip2long and long2ip analysis
- [pytorch practice] use pytorch to realize image style migration based on neural network
猜你喜欢
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
[statistical learning method] learning notes - support vector machine (I)
leetcode刷题:二叉树21(验证二叉搜索树)
3D content generation based on nerf
[pytorch practice] use pytorch to realize image style migration based on neural network
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
【无标题】
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
基于NeRF的三维内容生成
visual stdio 2017关于opencv4.1的环境配置
随机推荐
.Net下極限生產力之efcore分錶分庫全自動化遷移CodeFirst
[learn micro services from 0] [02] move from single application to service
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion
图形对象的创建与赋值
leetcode刷题:二叉树19(合并二叉树)
环境配置篇
Enterprise custom form engine solution (XII) -- experience code directory structure
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
What kind of methods or functions can you view the laravel version of a project?
Several ways to clear floating
[pytorch practice] write poetry with RNN
通讯协议设计与实现
[statistical learning methods] learning notes - Chapter 5: Decision Tree
Leetcode brush questions: binary tree 19 (merge binary tree)
ClickHouse(03)ClickHouse怎么安装和部署
@Resource和@Autowired的区别?
What are the benefits of ip2long?
聊聊Redis缓存4种集群方案、及优缺点对比
Adopt a cow to sprint A shares: it plans to raise 1.85 billion yuan, and Xu Xiaobo holds nearly 40%