Sponsored Content
Full Discussion: echo using single quotes
Top Forums Shell Programming and Scripting echo using single quotes Post 302142498 by earnstaf on Friday 26th of October 2007 03:15:10 PM
Old 10-26-2007
If I understand your problem, you are trying to do:
Code:
echo 'why doesn't this work?'

You'll need to escape the inner ' so it is seen literally.

Code:
echo 'shouldn\'t this work fine?'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Double quotes or single quotes when using ssh?

I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example, $ ITSME=itsme $ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME" itsme $ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME' itsyou $... (3 Replies)
Discussion started by: password636
3 Replies

2. Shell Programming and Scripting

echo is striping mah quotes

As the title says, echo is striping my quotes and I need them. echo "<?xml version="1.0" encoding="ISO-8859-1"?>" returns: <?xml version=1.0 encoding=ISO-8859-1?> Obviously, echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" returns the result I need: <?xml version="1.0"... (3 Replies)
Discussion started by: s_becker
3 Replies

3. Shell Programming and Scripting

Single quotes and double quotes

Hi guys, I have a sed line in double quotes which works fine, but I want it to be in single quotes here is the sed line sed "/abc_def/s/\'.*\'/\'\${abc_def}\'/" can some one give the equivalent to the above script in single quotes Thanks a ton (5 Replies)
Discussion started by: sol_nov
5 Replies

4. Shell Programming and Scripting

Perl echo with double quotes

I need to echo a string that has double quotes in a Perl script. #!/usr/bin/env perl `echo Rule123 -comment \"blah blah\" >> $filename` I'd like to get below appended to $filename: Rule 123 -comment "blah blah" But instead, the double quotes are lost: Rule 123 -comment blah bah ... (1 Reply)
Discussion started by: slchin
1 Replies

5. Shell Programming and Scripting

problem with echo inserting single quotes

Consider the following script: #!/bin/bash exclude='Archive PST,SystemState' IFS=$"," rsyncExclusions=$(for exclude in ${exclude}; do echo -n -e --exclude=\"${exclude}\"\ ; done) unset IFS echo rsync $rsyncExclusions test rsync -avh --delete --delete-excluded "$rsyncExclusions"... (7 Replies)
Discussion started by: jelloir
7 Replies

6. UNIX for Dummies Questions & Answers

grep single quotes or double quotes

Unix superusers, I am new to unix but would like to learn more about grep. I am very familiar with regular expressions as i have used them for searching text files in windows based text editors. Since I am not very familiar with Unix, I dont understand when one should use GREP with the... (2 Replies)
Discussion started by: george_vandelet
2 Replies

7. Shell Programming and Scripting

Replace single quote with two single quotes in perl

Hi I want to replace single quote with two single quotes in a perl string. If the string is <It's Simpson's book> It should become <It''s Simpson''s book> (3 Replies)
Discussion started by: DushyantG
3 Replies

8. Shell Programming and Scripting

Having a terrible problem with quotes/single quotes!

Hello. I'm trying to write a bash script that uses GNU screen and have hit a brick wall that has cost me many hours... (I'm sure it has something to do with quoting/globbing, which is why I post it here) I can make a script that does the following just fine: test.sh: #!/bin/bash # make... (2 Replies)
Discussion started by: jondecker76
2 Replies

9. 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

10. Shell Programming and Scripting

Issue with Single Quotes and Double Quotes for prompt PS1

Hi, Trying to change the prompt. I have the following code. export PS1=' <${USER}@`hostname -s`>$ ' The hostname is not displayed <abc@`hostname -s`>$ uname -a AIX xyz 1 6 00F736154C00 <adcwl4h@`hostname -s`>$ If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies
echo(1) 						      General Commands Manual							   echo(1)

NAME
echo - Writes its arguments to standard output SYNOPSIS
echo [-n] [string...] [Tru64 UNIX] The -n option is valid only if the environment variable CMD_ENV is set to bsd. Note The C shell has a built-in version of the echo command. If you are using the C shell, and want to guarantee that you are using the command described here, you must specify the full path /usr/bin/echo. See the csh(1) reference page for a description of the built-in command. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: echo: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] No newline is added to the output. The -n option is valid only if the environment variable CMD_ENV is set to bsd. Otherwise any -n operand is treated as a string rather than as a option. See the printf(1) reference page for use in portable applications. OPERANDS
The string to be displayed on standard output. The echo command recognizes the following special characters in the string: Displays an alert character. Displays a backspace character. Suppresses the newline character. All characters following c in the arguments are ignored. Displays a formfeed character. Displays a newline character. Displays a carriage-return character. Displays a tab character. Displays a vertical tab character. Displays a backslash character. Displays an 8-bit character whose value is the 1-, 2- or 3-digit octal number, number. The first digit of number must be a 0 (zero). DESCRIPTION
The echo command writes the specified string to standard output, followed by a newline character. The arguments are separated by spaces. Use the echo command to produce diagnostic messages in command files and to send data into a pipe. If there are no arguments, the echo command outputs a newline character. [Tru64 UNIX] The echo command described here is the program /usr/bin/echo. Both csh and sh shells contain built-in echo subcommands, which do not necessarily work in the same way as the /usr/bin/echo command. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To write a message to standard output, enter: echo Please insert diskette . . . To display a message containing special characters as listed in DESCRIPTION, enclose the message in quotes, as follows: echo " I'm at lunch. I'll be back at 1 p.m." This skips three lines and displays the message: I'm at lunch. I'll be back at 1 p.m. Note You must enclose the message in quotation marks if it contains escape sequences such as . Otherwise, the shell treats the back- slash () as an escape character. The previous command example, entered without the quotes, results in the following output: nnnI'm at lunch.nI'll be back at 1 p.m. To use echo with pattern-matching characters, enter: echo The back-up files are: *.bak This displays the message The back-up files are: and then displays the file names in the current directory ending with To add a sin- gle line of text to a file, enter: echo Remember to set the shell search path to $PATH. >>notes This adds the message to the end of the file notes after the shell substitutes the value of the PATH shell variable. To write a message to the standard error output (sh only), enter: echo Error: file already exists. >&2 Use this in shell procedures to write error messages. If the >&2 is omitted, then the message is written to the standard output. ENVIRONMENT VARIABLES
The following environment variables affect the execution of echo: [Tru64 UNIX] This variable must set to bsd for the -n option to be valid. Otherwise any -n operand is treated as a string member. Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: csh(1), ksh(1), printf(1), Bourne shell sh(1b), POSIX shell sh(1p) Environment: environ(5) Standards: standards(5) echo(1)
All times are GMT -4. The time now is 03:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy