Marco Linux Notes (4th Day file Management, command aliases, and Glob)

Source: Internet
Author: User
Tags aliases glob egrep

File Management:

Cp,mv,rm

Copy command: CP

CP [option] Source dest

CP [option] Source directory

CP [option]-T directory source

CP sec dest

If the target does not exist: Creates a new dest and fills the contents of SRC into the dest;

If the target exists:

If Dest is a file: overwrite

It is recommended that you use the-i option for the CP command to prompt before overwriting

If Dest is a directory: Create a file with the same name as the source file in the Dest directory

CP sec ... Dest

SEC ... : Multiple Files

At this point the dest must exist and be a directory, and other cases will be faulted

CP sec dest

SEC is directory: directory replication is not supported by default

Copy files in directories and directories using the-R recursive replication

If Dest does not exist:

Create a directory with the same name as the source directory

If dest exists:

If Dest is a file: Error

If dest is directory: Copy all Files under the SEC directory to the Dest directory

Common options:

-I: Interactive

-R: Recursively replicate directories and all internal content

-A: archive, preserving all meta attributes

-v:--verbose More information

-f:--force Mandatory

Mv:move

Command format:

MV [option] Source dest

MV [option] Source directory

MV [option] ...-t directory source

Common options:

-I: Interactive

-f:--force Mandatory

Rm:remove, deleting

Command format:

RM [OPTION] ... FILE ...

Common options:

-R: Recursive (can be used to delete directories)

-F: Force delete

Text Editor:

Nano

Nano file

Bash's foundation-specific (2):

1. Command Aliases (alias)

Implemented by the alias command, which is the shell's internal key command (use Help alias to view assistance)

(1) Alias

Displays all available command aliases for the current shell process

(2) Alias Name= ' VALUE '

Defines the alias name, which is equivalent to executing the command value

Instance:

Alias cdnet= ' Cd/etc/sysconfig/network-scripts '

[Email protected]_it ~]# cdnet

[[Email Protected]_it network-scripts]#

Note: Aliases defined on the command line, only for all available command aliases for the current shell process, and the shell does not take effect

If you want to work permanently, define it in the configuration file:

For the current user only: ~/.BASHRC

Valid for all users:/ETC/BASHRC

Attention:

Does not take effect immediately for SHELL,BASHRC that are already open

You can use source BASHRC to make file overloading effective

Or

. /path

To revoke an alias:

Unalias:

Unalias:unalias [-A] name [name ...]

Options:

-A: Revoke all aliases

Unalias name: Revoke an alias

Instance:

[Email protected]_it network-scripts]# Unalias cdnet

[Email Protected]_it network-scripts]# Alias

Alias cp= ' Cp-i '

Alias egrep= ' Egrep--color=auto '

Alias fgrep= ' Fgrep--color=auto '

Alias grep= ' grep--color=auto '

Alias l.= ' ls-d. *--color=auto '

Alias ll= ' Ls-l--color=auto '

Alias ls= ' ls--color=auto '

Alias mv= ' Mv-i '

Alias rm= ' Rm-i '

Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '

[[Email Protected]_it network-scripts]#

Do not use aliases, use the original command, you can use \command, such as \CP

2, Glob (globbing)

Used in bash to implement file name "wildcard"

Pass and Pay: *,? ,[]

1. *

Any character of any length (0-Infinity)

A*b: File ending with a beginning B

2.?

A character

There's a character between A?b:a and B.

3. []

Matches any single character within the specified range

[ABC] can only match in ABC

[0-9]

[A-Z]: character case insensitive

Instance:

LS a[0-9]b

Marco Linux Notes (4th Day file Management, command aliases, and Glob)

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.