Linux Basics-6

Source: Internet
Author: User

Lao Mo finally began to learn the order.

First, redirect

Before old Mo said the problem of over-orientation, the data stream sent to stdout was forwarded to the file.

cat /etc/os-release > 1.txt

Send the results to 1.txt, but note that if the file already exists then overwrite , if do not want to overwrite, but then enter (append), need to use >> . Automatically created for append if the file does not exist before.

ls / > 1.txtcat /etc/os-release >> 1.txt
Second, print the string
echo stringecho how are you?

Echo is the command, followed by the string, and the execution is output.

Third, copy the file
cp [option] {source} {targetr}cp [option] {source ... } {DIRECTORY}

The first form copies a copy of the file, and the second copies the files to a directory.

Copy Directory

cp -r s_directory  d_directory

-R can be written as-R or--recursive to recursively replicate the contents of the directory (that is, to replicate the directory tree).

Iv. deletion of files
rm [option] {files ... }

Delete the file from the file system, you cannot delete the directory by default, and you can remove the directory by adding the-r option.

Five, move and re-order
mv [option] {source} {target}mv [option] {source ...} {directory}

The first case is renamed, and the second case moves one or more files to a directory.

Vi. Creating a Directory
mkdir [option] {directory}

If the created directory does not exist, an empty directory is created. You can create multiple catalogs at once, or you can create a directory tree (that is, a multilevel directory).

Vii. Display Table of Contents
ls [option] {files ...}

Lists the contents of the entire directory, and if there are subdirectories in the directory that can be recursively displayed with-R, the entire directory tree is displayed.

By default, the contents of the current working directory are displayed, and the-r option shows the entire directory tree, and we find that images has two subdirectories boy,girl, and girl has a lili.jpg image file.

Eight, delete empty directory
rmdir [option] {directory ... }

By looking at the directory tree, you find that software is empty, and images is not empty. Delete these two directories, where images is not empty and the deletion fails, while software is empty for the deletion to succeed.

If deleting a directory tree can be used with Rm-r directory, note that this is dangerous, check before executing.

Linux Basics-6

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.