Unable to echo the content


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to echo the content
# 1  
Old 02-20-2013
Unable to echo the content

Hello,

'echo' command is not printing the exacting content as I needed.

I'm trying below, which is not echoing the correct content.

Code:
echo "XYZ\\`hostname`-volume" >> 123
# cat 123
XYZ

Where, It suppose to get
Code:
# cat 123
XYZ\hostname-volume


Please let me know how to resolve.

Thank you.
# 2  
Old 02-20-2013
It works for me on HP-UX, Linux & SunOS
Code:
echo "XYZ\\`hostname`-volume"
XYZ\mycomputer-volume

OR
Code:
echo "XYZ\\$(hostname)-volume"
XYZ\mycomputer-volume

What is your OS & SHELL?
# 3  
Old 02-21-2013
It work for me as well. Your syntax is fine. Can you check what output you are getting after typing
Code:
hostname

.
# 4  
Old 02-21-2013
Yes, it works fine for most of my OS and shells.

Is there any command that we have to put above the echo command so that it will take particular shell?

This will only fail on few things, wondering how to fix that?
# 5  
Old 02-21-2013
Put a Shebang in the beginning of your script.

E.g.
Code:
#!/bin/bash

# 6  
Old 02-21-2013
I have # /usr/bin/ksh on the top of my script.

Is there any other way to solve this problem? Like using 'set'??
# 7  
Old 02-21-2013
Just put below line on top of your script:
Code:
#!/usr/bin/ksh

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to print "|" in echo

I have a small script that works well but when I am putting pipes at the end of the echo command, output is getting weird. My script it below: sed '1d' CONTROL_TOTALS_*.txt | while read eachline do tblnm=`echo $eachline | cut -d'_' -f3` if then stg_tblnm='PROVIDER_CONTRACT' elif then... (6 Replies)
Discussion started by: svks1985
6 Replies

2. Shell Programming and Scripting

Facing issues with Content-Type:application/x-download Content-Disposition:attachment

I am in the process of developing a perl cgi page. I had succeeded in developing the page but there are few errors/issues with the page. description about cgi page: My CGI page retrieves all the file names from an directory and displays the files in drop down menu for downloading the... (5 Replies)
Discussion started by: scriptscript
5 Replies

3. Shell Programming and Scripting

Unable to echo single quotes inside awk

# echo 'export HISTFILE=/var/log/history/history_$(uname -n)_$(date +%Y:%b:%d:%H:%M)_$(who am i | awk '{print \$1}')' >> new_file # # cat new_file export HISTFILE=/var/log/history/history_$(uname -n)_$(date +%Y:%b:%d:%H:%M)_$(who am i | awk {print $1}) # Now how to echo the quotes around the... (2 Replies)
Discussion started by: proactiveaditya
2 Replies

4. Shell Programming and Scripting

Help with remove duplicate content and only keep the first content detail

Input data_10 SSA data_2 TYUE data_3 PEOCV data_6 SSAT data_21 SSA data_19 TYUEC data_14 TYUE data_15 SSA data_32 PEOCV . . Desired Output data_10 SSA data_2 TYUE data_3 PEOCV data_6 SSAT data_19 TYUEC (9 Replies)
Discussion started by: patrick87
9 Replies

5. Shell Programming and Scripting

With that logic this echoes "echo". Question about echo!

echo `echo ` doesn't echoes anything. And it's logic. But echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo" (too much echoing :P):o (2 Replies)
Discussion started by: hakermania
2 Replies

6. AIX

Unable to get the full content into a file when I redirect installp command output..

When i use the command to check the preview of the filesets to be installed using CLI # When using this commad 'm able to see all Preview view of the filesets to be installed installp -apgX -d "." all # When I redirected the same output to a file 'm able to see only half the details... (1 Reply)
Discussion started by: Sounddappan
1 Replies

7. Shell Programming and Scripting

sed, awk [TAG]$content[/TAG] How to get var in $content in textfile?

Hello, I got a Qstion. Im posting to a phpbb forum with bash and curl.. i have a text file with the following tags that i post to the forum: $var1 $var2 $var3 How can i with sed or awk put var content from shell script between the ... in the... (7 Replies)
Discussion started by: atmosroll
7 Replies

8. UNIX for Dummies Questions & Answers

How to correctly use an echo inside an echo?

Bit of a weird one i suppose, i want to use an echo inside an echo... For example... i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos... echo "echo "hello"" >$file echo "echo "goodbye"" >$file ... (3 Replies)
Discussion started by: mokachoka
3 Replies

9. Shell Programming and Scripting

Difference between using "echo" builtin and /bin/echo

So in my shell i execute: { while true; do echo string; sleep 1; done } | read line This waits one second and returns. But { while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly. I have tried this in bash as well as zsh,... (2 Replies)
Discussion started by: ulidtko
2 Replies
Login or Register to Ask a Question