Both single quotes and double quotes can disable shell processing for special characters. The difference is that double quotes do not have strict single quotes. Single quotes disable all characters with special functions, while double quotes only require shell to ignore the majority. Specifically, it is the dollar sign (②), the quotation mark (③), and The backslash. These three special characters are not ignored. The dollar sign is not ignored, which means shell also replaces variable names in double quotes.
The following describes how to use a simple shell program.
Debian :~ /Learn/shell # cat phonebook
Alice Chebba 973-555-2015
Barbara Swingle 201-555-9257
Liz Stachiw 212-555-2298
Susan Goldberg 201-555-7776
Susan Topple 212-555-4932
Tony Iannino 973-555-1295
Stromboli Pizza 973-555-9478
Debian :~ /Learn/shell #
Debian :~ /Learn/shell # cat lu
# Look someone up in the phone book
Grep "$1" phonebook
Debian :~ /Learn/shell #
This is the correct lu program. The following shows the running result.
Debian :~ /Learn/shell #./lu Susan T
Susan Topple 212-555-4932
Debian :~ /Learn/shell #./lu Tony
Tony Iannino 973-555-1295
Debian :~ /Learn/shell #
If lu is written as ① grep $1 phonebook or ② grep $1 phonebook, the following error occurs (Why ?).
Result 1:
Debian :~ /Learn/shell #./lu Tony // The result is correct.
Tony Iannino 973-555-1295
Debian :~ /Learn/shell #./lu Susan T // The result is incorrect.
Grep: T: No such file or directory
Phonebook: Susan Goldberg 201-555-7776
Phonebook: Susan Topple 212-555-4932
Debian :~ /Learn/shell #
② Results:
Debian :~ /Learn/shell #./lu Tony // The result is incorrect.
Debian :~ /Learn/shell #./lu Susan T // The result is also incorrect.
Debian :~ /Learn/shell #