That filename template doesn’t match “badge.txt,” though, because the filename doesn’t have a single character between “badge” and the file extension. The question mark wildcard will match both letters and numbers. Note that some have numbers and some have letters after the “badge” portion of the filename. This translates as “list any file with a name that starts with ‘badge’ and is followed by any single character before the filename extension.” Consider the following filename template: ls badge?.txt The question mark wildcard represents exactly one character. A filename that contains a wildcard forms a template that matches a range of filenames, rather than just one. You use wildcards to replace characters in filename templates. We can use echo to print the value of the string variable once more and check this: echo $this_stringīash shell supports three wildcards, one of which is the question mark (?). This doesn’t change the value stored in the string variable it only affects what’s sent to echo. Because we append the hash and the text “Dave,” it trims off that portion of the string before it’s passed to echo. It retrieves the value stored in the string variable via a parameter expansion. This command uses echo to print the words “How-To” to the terminal window. In this example, we assign the text “Dave Geek!” to the variable. This command creates a string variable called this_string. You can also use the hash to trim a string variable and remove some text from the beginning. It isn’t truly ignored, however, because it’s added to your command history. You can use it in shell scripts and-less usefully-on the command line.
Most often, you use the hash or number sign (#) to tell the shell what follows is a comment, and it should not act on it. Because everything in the Linux directory tree starts at the root directory, you can use this command to move to the root directory quickly: cd /
One forward-slash represents the shortest possible directory path. You can use a forward-slash (/)-often just called a slash-to separate the directories in a pathname. You hop up one level, and then back down one into a different directory. You can also use this technique to move quickly to a directory at the same level in the directory tree as your current one. You can also use this command with relative paths-for example, if you want to go up one level in the directory tree, and then enter another directory at that level. You can use this to move up one level in the directory tree. The double period or “double dot” (.) represents the parent directory of your current one. This way, it won’t search the directories in your path for matching executable or script. This tells Bash to look in the current directory for the script.sh file. For example, if you want to run a script from the current directory, you would call it like this. You can also use the period in commands to represent the path to your current directory. You see it in directory listings if you use the -a (all) option with ls. For example, if you’re somewhere in the file system that’s not under your home folder and want to change to the archive directory in your work directory, use the tilde to do it: cd ~/work/archiveĪ period (.) represents the current directory.
You can also use this command with relative paths.