Detailed explanation of Linux command file overwrite and file append

Detailed explanation of Linux command file overwrite and file append

1. The difference between the command > and >>

Command>: If the file exists, overwrite the original file's contents; if the original file does not exist, create the file and then add the information.
Command >>: will not overwrite the original file content, but append the content to the end of the file.

2. Basic grammar (just understand the difference between > and >>)

Basic syntax Functional Description
ls -l >filename Write the list contents to file
ls -l >filename Append the contents of the list to the end of the file
cat file1 > file2 Overwrite the contents of file 1 to file 2
echo "content" > filename Write the contents to the file

3. Example:

ls -l > filename:

ls -l >>filename:

Other commands are similar. I won’t go into details, you can verify it yourself.

The above is the detailed explanation and integration of Linux command file overwriting and file appending introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Summary of useful commands such as clearing files in Linux
  • How to use cp command to implement forced overwrite function in Linux system
  • Linux background running node service command method
  • Summary of Linux daily commonly used commands and applications
  • Summary of common Linux commands under Ubuntu
  • Detailed explanation of info command in Linux
  • A brief discussion on whoami and who commands in Linux
  • Detailed explanation of the Crontab command in Unix/Linux
  • In-depth explanation of Linux grep command (practical)

<<:  What scenarios are not suitable for JS arrow functions?

>>:  mysql5.6.8 source code installation process

Recommend

Detailed analysis of the chmod command to modify file permissions under Linux

Use the Linux chmod command to control who can ac...

Display mode of elements in CSS

In CSS, element tags are divided into two categor...

Ansible automated operation and maintenance deployment method for Linux system

Ansible is a new automated operation and maintena...

Detailed installation tutorial of zabbix 4.04 (based on CentOS 7.6)

1. Preparation before installation: 1.1 Install J...

Instructions for using MySQL isolation Read View

Which historical version can the current transact...

Detailed explanation of the use of grid properties in CSS

Grid layout Attributes added to the parent elemen...

MySQL Optimization Summary - Total Number of Query Entries

1. COUNT(*) and COUNT(COL) COUNT(*) usually perfo...

Invalid solution when defining multiple class attributes in HTML

In the process of writing HTML, we often define mu...

Convert psd cut image to div+css format

PSD to div css web page cutting example Step 1: F...

MySQL Billions of Data Import, Export and Migration Notes

I have been taking a lot of MySQL notes recently,...

Quick understanding of Vue routing navigation guard

Table of contents 1. Global Guard 1. Global front...

Docker cleanup environment operation

Start cleaning carefully! List unused volumes doc...

What does mysql database do?

MySQL is a relational database management system....

How to use Samba to build a shared file service on a Linux server

Recently, our small team needs to share a shared ...

Implementation of remote Linux development using vscode

Say goodbye to the past Before vscode had remote ...