HakTip

Hosted by Darren Kitchen and Shannon Morse.

Whether you're a beginner or a pro, HakTip is essential viewing for current and aspiring hackers, computer enthusiasts, and IT professionals. With a how-to approach to all things Information Technology, HakTip breaks down the core concepts, tools, and techniques of Linux, Wireless Networks, Systems... Read More

The Importance of Quotes In The Terminal

Friday, November 9th, 2012 – running time 06:00

This week we check out single and double quotes in the Linux terminal.

Using quotes is pretty simple, but is a good thing to know. If you notice your expansion command going haywire, you can use quotes to suppress it. Type ls -l hak5 technolust.txt. You get an error. Using double quotes around the name of this text document will fix this error. Double quotes make any special characters inside the quotes lose their meaning except for ` (backtick), \ (backslash), and $. The suppressed ones are word splitting, pathname / tilde / brace expansion, but parameter / arithmetic expansion and command substitution still work. In our hak5 technolust example, the word splitting is still read, so we get that error. Now type ls -l "hak5 technolust.txt" and you get the correct output. From here we can mv "hak5 technolust.txt" to hak5_technolust.txt.

Try using single quotes for your arguments. Single quotes suppress the expansion even farther. For example: echo text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER, now add double quotes around text---USER, and try adding single quotes around it. After the break - how to suppress a character inside your quotes.

There is a way to suppress just one character inside your quotes. For example, since we know the $ will still expand in the output, we want to make sure it reads as just a $ during it's output. Type: echo "This costs $10.00". Now type: echo "This costs \$10.00". Keep in mind that the first 32 ASCII characters all do something different when proceeded by a \. By typing something like echo -e "Trust your technolust\a" or echo "Trust your technolust" $'\a' you'll get a bell alert on your computer.

Quoting is as necessary as anything in the shell, and it's incredibly useful. Make sure to email me tips@hak5.org with your thoughts. And be sure to check out our sister show, Hak5 for more great stuff just like this. I'll be there, reminding you to trust your technolust.

Connect with HakTip

  • 19 days ago

    Hackers!! Our new episode of Hak5 will be posting soon! It's jam packed with epic interviews this week, so stay tuned!

  • 19 days ago

    @michael_a_nass Are you enjoying the awesomeness that is Hack Across America?

  • 19 days ago

    @jardinesoftware Thanks for the bump! The Throwing Star LAN Tap Pro is one of my favorite tools (though, I prefer soldering mine! :) -@snubs

  • about a month ago

    Employers want social media passwords, US gets a #CPO, and #TheOnion! All that and more this time on #ThreatWire! http://t.co/SrZpicvnt6

  • about a month ago

    #Installing #Solar panels, #Google #Chrome #extensions, and more on @Hak5! http://t.co/QppYLgZpi5

  • about a month ago

    Legalizing #Internet eavesdropping, #LivingSocial is #hacked, and more on this weeks #ThreatWire! http://t.co/xyIxzy8kes

About the Show

Details
Show Title:
HakTip
Description:
Whether you're a beginner or a pro, HakTip is essential viewing for current and aspiring hackers, computer enthusiasts, and IT professionals. With a how-to approach to all things Information Technology, HakTip breaks down the core concepts, tools, and techniques of Linux, Wireless Networks, Systems Administration, and more
Categories:
How-To & DIY, Technology & Gadgets
Launch Date:
May 23, 2011
Episodes: