You might be working on a file that is important to you and do not want to mess it up, the best thing to do is backup the file and then do what you want to do just to be on the safe side, lets see example of how to do this using Linux/Unix command,
Option 1: Backup a file using cp command as a new file
# cat my-important-file.txt
This is one of my
very important
text file.
As you can see I have a file that I want to change, but before change it I want to take a backup of It, lets do that using the cp command,
# cp my-important-file.txt my-important-file-backup.txt
As you can see using the copy command, I took a backup of the file my-important-file.txt in a new file that I named as my-important-file-backup.txt, now lets see if the content of the file is same or not,
cat my-important-file-backup.txt
This is one of my
very important
text file.

Option 2: Backup a file with the same name at a different location
# cp my-important-file.txt /home/
# cd /home/
# ls
my-important-file.txt
# cat my-important-file.txt
This is one of my
very important
text file.
More Posts related to Linux,
- Terminal display next month Calendar
- How to change bash terminal prompt string and color
- How to exit from nano command
- How to Display content of a file in Terminal Screen?
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- 3 Commands to stop Nginx Server
- How to check file permissions for your file using Linux/Unix/macOS Terminal Command
- Create Hidden File or Directory using Shell Command
- bash: cls: command not found
- How to install python pip on Ubuntu using apt command
- The Date Command and its usage [Linux - Unix - macOS]
- SCP Copy all files from directory to Local Folder
- Create and write file in single Linux/macOS command
- Install OpenSSL on Linux/Ubuntu
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- Check SSH/OpenSSH version Command
- Execute .bin and .run file Ubuntu Linux
- What does apt-get update command does?
- How to ls command to output one entry per line [macOS/Linux/Bash]
- 3 ways to clear screen on Linux Terminal
- How to backup a file in Linux/Unix
- How to quit or exit SFTP Prompt on Terminal
- How to use SCP Command to Copy Directory
- zsh hello world example
- How to remove/delete a directory in Linux/macOs
More Posts:
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds - Java
- Is Facebook is down? Is it just for me? - Facebook
- Create Custom Toast Android Programming - Android
- [FIX] AndroidRuntime: FATAL EXCEPTION: main - java.lang.RuntimeException NullPointerException - Android
- PHP Base64 encoding decoding a variable - PHP
- Java was started but returned exit code=13 [Eclipse] - Eclipse
- Error 404 Tomcat homepage http://localhost:8080/ not displayed - Tomcat
- Javascript convert text case from uppercase to lowercase - JavaScript