LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
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: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
Awesome thank you.
 
1 members found this post helpful.
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration