LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-09-2011, 06:43 PM   #1
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 977

Rep: Reputation: 56
How to pass a single quote inside of a single quote...


Here's a command I have to monitor my 3 computers in my lan.
Code:
watch 'printf "BSD\n" && ssh bsd ps u && printf "\n" && ssh bsd iostat && printf "\n################################################################################################################################################\n\nCentOS\n" && ssh centos ps u && printf "\n" && ssh centos iostat && printf "\n################################################################################################################################################\n\nDarkstar\n" && ps u && printf "\n" && iostat'
But I'd like to clean it up and make it look like this. However, the perl -e 'print "#"x145' has single quotes which ends up closing the first single quote at watch 'printf.
Code:
watch 'printf "BSD\n" && ssh bsd ps u && printf "\n" && ssh bsd iostat && printf "\n" && perl -e 'print "#"x145' && printf "\n\nCentOS\n" && ssh centos ps u && printf "\n" && ssh centos iostat && prin
tf "\n" && perl -e 'print "#"x145' && printf "\n\nDarkstar\n" && ps u && printf "\n" && iostat'
Any way around that?
 
Old 02-09-2011, 07:02 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,604

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi,

if you want to escape a single quote inside single quotes you can do it with the following sequence:
Code:
'\''
You actually close the single quote, escape the single quote and then reopen it. Example:
Code:
echo 'quote'\''s'
 
Old 02-09-2011, 07:07 PM   #3
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 977

Original Poster
Rep: Reputation: 56
Awesome thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xargs: unmatched single quote akudewan Linux - Newbie 5 07-28-2014 12:16 PM
instead of single quote char in debian man ? Vilius Debian 1 01-25-2011 04:43 AM
[SOLVED] escaping a single quote from a bash script atbrew Programming 8 07-21-2010 09:21 AM
[SOLVED] How to escape single quote btacuso Linux - Newbie 3 03-11-2010 10:58 AM
xargs: unmatched single quote fillatre Linux - Software 2 06-05-2004 10:04 PM


All times are GMT -5. The time now is 04:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration