Get the App
SLTechnology News&Howtos  ›  Servers  › 

Notes on the principles and applications of Unix-Chapter V General document 1

Shulou Source: shulou.com Published: 2022-06-03 05:49:49 09月21日 Update

Display and create file command: cat (usually only text file contents are displayed)

Common options explain:-v: display non-print characters;-n: display line numbers

Create a file: enter the cat command, followed by the > character, and then enter a file name after it and press ctrl+d to end the entry

Purpose: create files, display file contents, link files, add content to the end of the file, and apply it to the stream.

The input to the Cat command can come from a file or from the output of other commands.

File copy command: cp

Principle: it can be used to copy a set of files, which generates an image of the source file on disk, but with a different file name.

Note: if the target file does not exist, create it before copying it.

Cp is often associated with "." Symbols are used together to copy files to the current directory. The following two commands are equivalent

For example: cp / home/sharma/.profile .profile

Cp / home/sharma/.profile.

The command is optional:

-I: interactive replication;-R: copy directory tree

Cp-R progs newprogs

Note: the correct execution of the above cp depends on the existence of the newprogs directory. If it does not exist, the cp command creates this directory and its subdirectories. But if it does, progs will copy into a subdirectory of newprogs and produce a completely different result.

Warning: sometimes files cannot be copied using the cp command, possibly because the source files are read-protected or the destination files and directories are write-protected.

File deletion command: rm

Usage: rm can only delete files, not directories

Note: whether you can delete a file is not determined by the permissions of the file, but by the permissions of the directory in which it is located.

The command is optional:-I: delete files interactively;-rUniverse: delete files recursively;-f: force deletion

Tags: File command directory input content interactive subdirectory subdirectory character file name is made up of permissions source files targets protection principles applications differences creativity reasons Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology Linux Redmi Apple