Skip to Content
Ubuntu: Up and Running
book

Ubuntu: Up and Running

by Robin Nixon
April 2010
Beginner
464 pages
12h 7m
English
O'Reilly Media, Inc.
Content preview from Ubuntu: Up and Running

Using Backticks

The backtick is a special type of quotation mark that you’ll usually find near the 1 key on your keyboard. You use it in a command line to tell Ubuntu to execute the contents between the ticks as a separate command, and then to paste the output in place of the backtick’s contents.

For example, you can combine some text with a command to display the current date like this:

echo "Today is `date`"

Or, to list the current working directory in a friendly way, you could use this command:

echo "You are in `pwd`"

Or here’s how you can list all the files in your home folder (and its subfolders) that have the file extension .txt:

echo -e "`clear`Your text files:\n\n`find ~ -name *.txt`";

As you can see, there are two uses of backticks here: once to clear the screen and again to search for the text files. The -e argument tells Ubuntu to allow escaped characters such as \n, which is used to display new lines.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu Made Easy

Ubuntu Made Easy

Rickford Grant, Phil Bull
Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9781449382827Errata Page