I am working with Ubuntu version 18.04.4 LTS. I tried to create a file using the following command: sudo cat > filename.yaml and received a "Permission denied error" I can create the file using the VIM editor and sudo. Please advise.
Asked
Active
Viewed 2,329 times
1 Answers
0
I'm not an expert on cat but I suspect the command as you've entered it above will produce an error by design. Cat is used to print and concatenate files.
Example commands with cat are cat filename.yaml which will print the contents of filename.yaml to standard output (i.e. the terminal); while cat file1.yaml file2.yaml > filename.yaml will combine the contents of the existing files file1.yaml and file2.yaml into a new file called filename.yaml.
Concrete_Buddha
- 171
cat, and reflects the user's lack of rights in the target directory), the commandcat > filenamewill indeed createfilename- however, it will hang waiting to read file contents from standard input. Simply hitting Ctrl-D will terminate the command, resulting in creation of an empty file, similar totouch filenameor> filename– steeldriver Jun 11 '20 at 22:18catstill probably won't be the first tool out of the box next time I want to create an empty file ;) – Concrete_Buddha Jun 12 '20 at 08:45