Command Line Variables and Globbing
This will show a little about how variables are used, including a simple function.
We have been using BASH, a program that is both a shell between us and the operating system, and a programming language. To add power to the command line, we can assign temporary variables, like this:
me@ubu:~$ d=/usr/bin me@ubu:~$ echo $d me@ubu:~$ ll $d
The equal sign assigned the characters
/usr/bin to the variable
b. In the
next two lines we checked our assignment by echoing it. We had to use the
dollar sign to indicate that it was a variable instead of the letter
b. Then we
did a listing of whatever was in the directory pointed to by
$b. I often use
s to represent the source and
d to represent the destination when
I am copying or moving files. It saves typing.
The term globbing means to use wildcards, usually with filenames. Suppose we want to find some programs that have to do with PDFs. We can use the variable we already made plus the asterisk that means "match anything" like this:
me@ubu:~$ ll $d/*pdf*
You could try using the man command to see which one is the one you want.