Chap5:操作文件和目录[The Linux Command Line]
Wildcard | Meaning |
---|---|
* | Matches any characters |
? | Matches any single character |
[characters] | Matches any character that is a member of the set characters |
[!characters] | Matches any character that is not a member of the set characters |
[[:class:]] | Matches any character that is a member of the specified class |
Character Class | Meaning |
---|---|
[:alnum:] | Matches any alphanumeric character |
[:alpha:] | Matches any alphabetic character |
[:digit:] | Matches any numeral |
[:lower:] | Matches any lowercase letter |
[:upper:] | Matches any uppercase letter |
Pattern | Matches |
---|---|
* | All files |
g* | All file beginning with "g" |
b*.txt | Any file beginning with "b" followed by any characters and ending with ".txt" |
Data??? | Any file beginning with "Data" followed by exactly three characters |
[abc]* | Any file beginning with either an "a", a "b", or a "c" |
BACKUP.[0-9][0-9][0-9] | Any file beginning with "BACKUP." followed by exactly three numerals |
[[:upper:]]* | Any file beginning with an uppercase letter |
[![:digit:]]* | Any file not beginning with a numeral |
*[[:lower:]123] | Any file ending with a lowercase letter or the numerals "1", "2", or "3" |
cp-Copy files and directories
Option | Meaning |
---|---|
-a, --archive | Copy the files and directories and all of their attributes, including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy |
-i, --interactive | Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files. |
-r, --recursive | Recursively copy directories and their contents. This option (or the -a option) is required when copying directories. |
-u, --update | When copying files from one directory to another, only copy files that either don't exist, or are newer than the existing corresponding files, in the destination directory. |
-v, --verbose | Display informative messages as the copy is performed. |
Command | Results |
---|---|
cp file1 file2 | Copy file1 to file2. If file2 exists, it is overwritten with the contents of file1. If file2 does not exist, it is created. |
cp -i file1 file2 | Same as above, except that if file2 exists, the user is prompted before it is overwritten. |
cp file1 file2 dir1 | Copy file1 and file2 into directory dir1. dir1 must already exist. |
cp dir1/* dir2 | Using a wildcard, all the files in dir1 are copied into dir2. dir2 must already exist. |
cp -r dir1 dir2 | Copy the contents of directory dir1 to directory dir2. If directory dir2 does not exist, it is created and, after the copy, will contain the same contents as directory dir1. If directory dir2 does exist, then directory dir1 (and its contents) will be copied into dir2. |
mv-Move/rename files and directories
Option | Meaning |
---|---|
-i --interactive | Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, mv command will silently overwrite files |
-u --update | When moving files from one directory to another, only move files that either don't exist, or are newer than the existing corresponding files in the destination directory. |
-v --verbose | Display informative messages as the move is performed. |
mv file1 file2 | Move file1 to file2. If file2 exists, it is overwritten with the contents of files. If file2 does not exist, it is created. In either case, file1 ceases to exist. |
mv -i file1 file2 | Same as above, except that if file2 exists, the user is prompted before it is overwritten. |
mv file1 file2 dir1 | Move file1 and file2 into dirctory dir1. dir1 must already exist. |
mv dir1 dir2 | if directory dir2 does not exist, create directory dir2 and move the contents of directory dir1 into dir2 and delete directory dir1. if directory dir2 does exist, move directory dir1 (and its contents) into directory dir2. |
mkdir-Create directories
Option | Meaning |
---|---|
-i, --interactive | Before deleting an existing file, prompt the user for confirmation. If this option is not specified, rm will silently delete files. |
-r, --recursive | Recursively delete directories. This means that if a directory being deleted has subdirectories, delete them too. To delete a directory, this option must be specified. |
-f, --force | Ignore nonexistent files and do not prompt. This overrides the --interactive option. |
-v, --verbose | Display informative messages as the deletion is performed. |
Command | Results |
---|---|
rm file1 | Delete file1 silently |
rm -i file1 | Same as above, except that the user is prompted for confirmation before the deletion is performed. |
rm -r file1 dir1 | Delete file1 and dir1 and its contents. |
rm -rf file1 dir1 | Same as above, except that if either file1 or dir1 do not exist, rm will continue silently. |
rm-Remove files and directories
ln-Create hard and symbolic links
Chap5:操作文件和目录[The Linux Command Line]的更多相关文章
- (三)linux 学习 --操作文件和目录
The Linux Command Line 读书笔记 - 部分内容来自 http://billie66.github.io/TLCL/book/chap05.html 文章目录 通配符 字符范围 ` ...
- 【Python】[IO编程]文件读写,StringIO和BytesIO,操作文件和目录,序列化
IO在计算机中指Input/Output,也就是输入和输出. 1.文件读写,1,读文件[使用Python内置函数,open,传入文件名标示符] >>> f = open('/User ...
- Python之IO编程——文件读写、StringIO/BytesIO、操作文件和目录、序列化
IO编程 IO在计算机中指Input/Output,也就是输入和输出.由于程序和运行时数据是在内存中驻留,由CPU这个超快的计算核心来执行,涉及到数据交换的地方,通常是磁盘.网络等,就需要IO接口.从 ...
- IO编程(2)-操作文件和目录
操作文件和目录 如果我们要操作文件.目录,可以在命令行下面输入操作系统提供的各种命令来完成.比如dir.cp等命令. 如果要在Python程序中执行这些目录和文件的操作怎么办?其实操作系统提供的命令只 ...
- Python学习笔记(二十五)操作文件和目录
摘抄:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014319253241 ...
- Linux 文件与目录管理,Linux系统用户组的管理
一.Linux 文件与目录管理 我们知道Linux的目录结构为树状结构,最顶级的目录为根目录 /. 其他目录通过挂载可以将它们添加到树中,通过解除挂载可以移除它们. 在开始本教程前我们需要先知道什 ...
- os,操作文件和目录
如果我们要操作文件.目录,可以在命令行下面输入操作系统提供的各种命令来完成.比如dir.cp等命令. 如果要在Python程序中执行这些目录和文件的操作怎么办?其实操作系统提供的命令只是简单地调用了操 ...
- python学习笔记 操作文件和目录
如果我们要操作文件.目录,可以在命令行下面输入操作系统提供的各种命令来完成.比如dir.cp等命令. 如果要在Python程序中执行这些目录和文件的操作怎么办?其实操作系统提供的命令只是简单地调用了操 ...
- IO编程、操作文件或目录、序列化、JSON
IO中指Input/Output,即输入和输出:涉及到数据交换的地方,通常是磁盘.网络等,就需要IO接口 1.由于CPU和内存的速度远远高于外设的速度,所以,在IO编程中,存在速度严重不匹配问题.eg ...
随机推荐
- 【Python】Python的安装与个人使用记录
下载 从官网上下载,目前,最新版是Python3,基于项目需求,我们使用的是Python2. 我是在CentOS上安装,下载的是Python-2.7.9.tgz. 安装 tar -zxvf Pytho ...
- SAP BW: Replacement Path Variables
How to use Replacement Path Variables to perform Date Calculations A Step-by-Step guide Have you eve ...
- ORA-03297: 文件包含在请求的 RESIZE 值以外使用的数据
本文中的45,对应 修改数据文件大小 里面的45 1.移动表前先对表空间做整理 alter tablespace data_cis_test coalesce; 2.在dba_extents找到与ID ...
- JVM 内部原理(三)— 基本概念之类文件格式
JVM 内部原理(三)- 基本概念之类文件格式 介绍 版本:Java SE 7 每位使用 Java 的程序员都知道 Java 字节码在 Java 运行时(JRE - Java Runtime Envi ...
- 大杂烩 -- Iterator 并发修改异常ConcurrentModificationException
基础大杂烩 -- 目录 大杂烩 -- Java中Iterator的fast-fail分析 大杂烩 -- Iterator 和 Iterable 区别和联系 问题: 在集合中,判断里面有没有" ...
- Flask框架(1)-程序基本结构
1. 安装Flask 1.1 安装虚拟环境 mkdir myproject cd myproject py -3 -m venv venv #Linux系统: python3 -m venv venv ...
- Diffuse Shading——漫反射光照改善技巧
转:http://www.narkii.com/club/thread-355113-1.html 我们会列出两种方法:使用Half Lambert lighting model(半兰伯特光照模型)和 ...
- 解决pycharm在ubuntu下搜狗输入法一直固定在左下角的问题
1.缩放VMware,当ubuntu中出现下拉导航条时,点击左上角查看>立即适应客户机,然后在pycharm中打中文的时候不用全屏,就可以看到输入法显示的文字了. 2.目前没有发现搜狗输入法版本 ...
- python网络编程之UDP方式传输数据
UDP --- 用户数据报协议(User Datagram Protocol),是一个无连接的简单的面向数据报的运输层协议. UDP不提供可靠性,它只是把应用程序传给IP层的数据报发送出去,但是并不能 ...
- http 本地服务器设置任意IP访问对应的文件夹
使用软件:wamp 一.配置apache的host访问路径 打开下面“wamp\bin\apache\Apache2.4.4\conf\”路径下的httpd.conf文件,然后我希望将“自定义IP”的 ...