How do I create a new file in a different directory? If the file exists it should also create a new file.
I am using the command:
Touch workdirectory/filename.txt
If you're using a window manager, you can usually press Ctrl + Alt + T to open a new terminal window. If not, log into the system on which you want to create a file through the console. Type cat > newfilename and press ↵ Enter . Replace newfilename with whatever you'd like to call your new file.
Additionally, you can use shortcut methods. Press the [Esc] key and type Shift + Z Z to save and exit or type Shift+ Z Q to exit without saving the changes made to the file.
Try > workdirectory/filename.txt
This would:
You can consider it equivalent to:
rm -f workdirectory/filename.txt; touch workdirectory/filename.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With