![]() Sample Output touch: missing file operand Anything after a # is interpreted as comment and hence neglected by BASH. The symbol # has a very different meaning in BASH. ![]() The same rule as discussed above follows for the name of the folder having any number of hypen and their occurrence, except the fact that for deleting the folder you have to use ‘ rm -rf‘ as: $ rm -rf -abcĭealing with files having HASH (#) in the name The same rule as discussed above follows for any number of hypen in the name of the file and their occurrence. If you have lots of files in a folder the name of which contains dash, and you want to delete all of them at once, do as: $ rm. Similarly to move such file you have to do: $ mv -abc.txt -a.txtĪnd to Delete this file, you have to do: $ rm -abc.txt Note: You may replace nano with any other editor of your choice say vim as: $ vim -abc.txt To edit the above file you may do: $ nano -abc.txt You may verify the file thus created by both the above ways by running commands ls or ls -l for long listing. ![]() There are two ways to resolve this error as: $ touch -abc.txt To resolve such error, we have to tell the Bash shell (yup this and most of the other examples in the article is for BASH) not to interpret anything after special character (here dash), as option. The reason for above error, that shell interprets anything after a dash (-), as option, and obviously there is no such option, hence is the error. Sample Output touch: invalid option - 'b' Dealing with file that has dash (-) in it’s nameĬreate a file that starts with a dash (-), say -abx.txt. Also speaking technically every thing be it folder, driver or anything else is treated as file in Linux. I Agree to you, that such file names are not common still your shell should not break/give up when you have to deal with any such file names. One of the most obvious question here is – who on earth create/deal with files/folders name having a Hash (#), a semi-colon ( ), a dash (-) or any other special character. Examples of file names that has special character and is not very common: #232.txt
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |