In bash, "Delete the file if it exists".

rm exist.txt 2> /dev/null

If it does not exist, this code will result in standard error. Then discard 2 of the standard error output to / dev / null.

reference https://qiita.com/i35_267/items/158cd20ed26f73a3d894

Recommended Posts

In bash, "Delete the file if it exists".
Check if the URL exists in Python
Delete a particular character in Python if it is the last
Check if the expected column exists in Pandas DataFrame
Read the csv file and display it in the browser
Check if it is Unix in the scripting language
Check if it is Unix in the scripting language
Download the file in Python
Can you delete the file?
[python] How to check if the Key exists in the dictionary
Save the binary file in Python
The story of the "hole" in the file
Check if the configuration file is read in an easy-to-understand manner
If I thought I didn't see the pyc file recently, it was quarantined in pycache by python3.
Django ~ Let's display it in the browser ~
The one that divides the csv file, reads it, and processes it in parallel
Read the file line by line in Python
View the full path (absolute path) of a file in a directory in Linux Bash
Read the file line by line in Python
Find it in the procession and edit it
If the conda environment is strange, let's put it back in mac
[Python] Read the specified line in the file
If you guys in the scope kitchen can do it with a margin ~ ♪
If an exception occurs in the function, it will be transmitted to the caller 2
If an exception occurs in the function, it will be transmitted to the caller 1
Delete vertices that meet the conditions in networkx
Check if the characters are similar in Python
File DL, byte value and delete in Python3
Determining if there are birds in the image
Extract the lyrics information in the MP3 / MP4 file and save it in the lyrics file (* .lrc) for Sony walkman.
Delete the substring
Bash in Jupyter
I want to replace the variables in the python template file and mass-produce it in another file.
Check if the string is a number in python
Download the file while viewing the progress in Python 3.x
Get the file name in a folder using glob
If there were no DI containers in the world.
[Django] Perform Truncate Table (delete all data in the table)
How to use the exists clause in Django's queryset
[IBM Cloud] Place the ISO file in the object storage
Determine if an attribute is defined in the object
Error in rsync to mount.cifs shared folder: File exists (17)
How to create a new file when the specified file does not exist — write if the file exists
It was great to edit the Python file in the Raspberry Pi with Atom's remote function
If you want to put an argument in the closure function and execute it later