It tells BASH that is a part of file name and not command separator. Note: We have enclosed the file name with single quote ''. To resolve such error, tell BASH not to interpret semicolon as command separator, as: $ touch. It also reports another error that ‘ abc.txt‘ command not found, only because after semicolon BASH was expecting another command and ‘ abc.txt‘, is not a command. The reason for above error, that when you run the above command BASH interpret touch as a command but could not find any file operand before semicolon and hence it reports error. Have you ever deal with any file name having semicolon in it? If not here you will.Ĭreate a file having semi-colon in it. Semicolon lets you execute several command in one go and acts as separator. In case you are not aware, semicolon acts as a command separator in BASH and perhaps other shell as well. #*ĭealing with files having semicolon ( ) in its name To delete all the files that has hash ( #) in the file name, you may use: # rm. You may edit it as using your choice of editor as: $ vi. To execute the above situation successfully we can do, $ touch a.txt. Obvious from the above example it only created file ‘ a‘ and file ‘ #bc‘ has been ignored. What happens when you create two files (say a and #bc) at once: $ touch a.txt #bc.txt Now create a file the name of which contains # anywhere except at the begging. #abc.txtĪnd verify the file just created as: $ ls -l To resolve such error, you may ask BASH not to interpret # as comment. So the command touch has been passed without any file Operand, and hence is the error. The reason for above error, that Bash is interpreting #abc.txt a comment and hence ignoring. 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.
HOW TO MAKE TILDE IN LINUX DRIVER
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