4,管理文件和路径

 

Wildcards

*

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

  

 

echo *

It might appear at first glance that we could include hidden files in an expansion by starting the pattern with a leading period, like this:

echo .*

It almost works. However, if we examine the results closely, we will see that the names . and .. will also appear in the results. Because these names refer to the current working directory and its parent directory, using this pattern will likely produce an incorrect result. We can see this if we try the following command:

ls -d .* | less

To better perform pathname expansion in this situation, we have to employ a more specific pattern

echo .[!.]*

This pattern expands into every filename that begins with only one period fol- lowed by any other characters. This will work correctly with most hidden files (though it still won't include filenames with multiple leading periods). The ls command with the -A option (“almost all”) will provide a correct listing of hid- den files.

ls -A

Commonly Used Character Classes
[:alnum:]

Matches any alphanumeric character

[:alpha:]

Matches any alphabetic character

[:digit:]

Matches any numeral

[:lower:]

Matches any lowercase letter

[:upper:]

Matches any uppercase letter

Wildcards can be used with any command that accepts filenames as arguments

1, cp

-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.

-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.

 

cp item... directory

copies multiple items (either files or directories) into a directory.

 

2,mv

mv item... directory

to move one or more items from one directory to another.

 

3,ln

The following creates a hard link:

ln file link

The following creates a symbolic link:

ln -s item link

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值