LinuxQuestions.org
Visit Jeremy's Blog.
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-16-2014, 01:45 AM   #1
AntBla
LQ Newbie
 
Registered: Oct 2012
Posts: 16

Rep: Reputation: Disabled
Problem echoing text to shell file with quotes in the middle of the echo command


Hi all.

I have a question that I think might be simple to answer, but I can't crack it after an hour or so of trying.
I am trying to create an installer.sh script that will create other shell scripts in the /usr/local/bin folder
The problem I have is that I want to use this line to echo the output to a file called test.sh

echo "ssh tunnel.somedomain.com.au "echo 2>&1" && echo host OK || sh /usr/local/bin/killtunnel.sh">>/usr/local/bin/test.sh

The line I want to appear in test.sh is
ssh tunnel.somedomain.com.au "echo 2>&1" && echo host OK || sh /usr/local/bin/killtunnel.sh

The problem I have is that there are quotes "" inside quotes which is not working.

Can anyone point me to the correct syntax? Or suggest a better way?

Thanks.

Ant.
 
Old 02-16-2014, 01:51 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,373

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
have you tried ' or \" ?
 
Old 02-16-2014, 05:56 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 5,802

Rep: Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381
...meaning:
Code:
echo '"ssh tunnel.somedomain.com.au "echo 2>&1" && echo host OK || sh /usr/local/bin/killtunnel.sh"' >> /usr/local/bin/test.sh
that should do it.
 
1 members found this post helpful.
  


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
Slackware64 --current - Echoing X window title into a text file slaka Linux - Newbie 1 07-12-2013 02:27 PM
[SOLVED] Difference between echo of file within double quotes and without double quotes ankitpandey Programming 2 01-11-2013 09:02 AM
Shell command/script to find duplicate strings in a text file damgar General 4 09-04-2012 01:17 PM
shell script: how to insert a command into quotes alekone Linux - General 4 01-12-2009 08:56 AM
Linux shell command for makefile.in to create a text file and write to it alix123 Programming 8 01-07-2005 08:18 AM


All times are GMT -5. The time now is 02: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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration