Sponsored Content
Top Forums Shell Programming and Scripting Bash shell adding extra single quotes Post 302670821 by hpodhrad on Thursday 12th of July 2012 01:21:05 PM
Old 07-12-2012
Bash shell adding extra single quotes

AIX 6.1
bash shell

Code:
#!/bin/bash -x
STATEMENT="cvs commit -m \"This is\" ../PBP/EIR.ENTRY"
echo $STATEMENT
exit 0

This is the output
+ STATEMENT='cvs commit -m "This is" ../PBP/EIR.ENTRY'
+ echo cvs commit -m '"This' 'is"' ../PBP/EIR.ENTRY
cvs commit -m "This is" ../PBP/EIR.ENTRY
+ exit 0

Problem: Notice the single quotes between "This" and "is" ... This causes the called program "cvs" to think those are separate parameters which they are not.

If I change the shell to this
Code:
#!/bin/bash -x
STATEMENT="cvs commit -m \"This is\" ../PBP/EIR.ENTRY"
echo $STATEMENT
$STATEMENT
exit 0

Then this is the ouput

+ STATEMENT='cvs commit -m "This is" ../PBP/EIR.ENTRY'
+ echo cvs commit -m '"This' 'is"' ../PBP/EIR.ENTRY
cvs commit -m "This is" ../PBP/EIR.ENTRY
+ cvs commit -m '"This' 'is"' ../PBP/EIR.ENTRY
cvs commit: nothing known about `is"'
cvs [commit aborted]: correct above errors first!
+ exit 0

Please do not pass this off as a "cvs" problem. It is not. If I change the script to this
Code:
#!/bin/bash -x
STATEMENT="cvs commit -m \"Thisis\" ../PBP/EIR.ENTRY"
echo $STATEMENT
$STATEMENT
exit 0

Then this is the output
+ STATEMENT='cvs commit -m "Thisis" ../PBP/EIR.ENTRY'
+ echo cvs commit -m '"Thisis"' ../PBP/EIR.ENTRY
cvs commit -m "Thisis" ../PBP/EIR.ENTRY
+ cvs commit -m '"Thisis"' ../PBP/EIR.ENTRY
+ exit 0

How do I get bash to ignore that space?

Last edited by joeyg; 07-12-2012 at 03:31 PM.. Reason: Please wrap data and sripts with CodeTags
 

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

How can i use single quotes for SQL command in shell script

Hi. please help me to write the following query in a shell script. the Query is :select no,salary from emp_info where name='$var_name' the following is my code. #! /bin/sh var_name=$1 sqlplus -s user/pwd@DB << EOF select no,salary from emp_info where name="'$var_name'";... (4 Replies)
Discussion started by: little_wonder
4 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

removing extra double quotes between pipe dilimeter

I have a flat file sample like this - "COURSE"|"ddddd " " dddd"|"sssddd sdsdsdsdx" dddddddd ffffff "aaaaa" dddddddd ffffff sdsdsd"|"xxxxxxx"| "COURSE"|"ffff " " bbbb"|"lllll"| The delimiter is pipe character (|) and the text are enclosed in double quotes... (5 Replies)
Discussion started by: vishalzone
5 Replies

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

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

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

8. Shell Programming and Scripting

shell script - to append single quotes and comma

file1 ---- 34556745 32678343 31576776 31455566 21356666 I want to assign the record values to a variable in the below format, so that I can use output in .sql file for querying in database. ('34556745', '32678343', '31576776', '31455566', '21356666') ----------- below is the... (11 Replies)
Discussion started by: rajivrsk
11 Replies

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

10. UNIX for Beginners Questions & Answers

Bash not recognizing single quotes in Mac?

Hi, I just bought a new mac and have been running a program out of terminal, but even early on I noticed that my single quotes looked a lot different from the ones used in all of the namelists and other files of the program. Specifically, mine are kind of slanted whereas the others are very... (7 Replies)
Discussion started by: jtcastro99
7 Replies
BASHBUG(1)						      General Commands Manual							BASHBUG(1)

NAME
bashbug - report a bug in bash SYNOPSIS
bashbug [--version] [--help] [email-address] DESCRIPTION
bashbug is a shell script to help the user compose and mail bug reports concerning bash in a standard format. bashbug invokes the editor specified by the environment variable EDITOR on a temporary copy of the bug report format outline. The user must fill in the appropriate fields and exit the editor. bashbug then mails the completed report to bug-bash@gnu.org, or email-address. If the report cannot be mailed, it is saved in the file dead.bashbug in the invoking user's home directory. The bug report format outline consists of several sections. The first section provides information about the machine, operating system, the bash version, and the compilation environment. The second section should be filled in with a description of the bug. The third sec- tion should be a description of how to reproduce the bug. The optional fourth section is for a proposed fix. Fixes are encouraged. ENVIRONMENT
bashbug will utilize the following environment variables if they exist: EDITOR Specifies the preferred editor. If EDITOR is not set, bashbug defaults to emacs. HOME Directory in which the failed bug report is saved if the mail fails. TMPDIR Directory in which to create temporary files and directories. SEE ALSO
bash(1) AUTHORS
Brian Fox, Free Software Foundation bfox@gnu.org Chet Ramey, Case Western Reserve University chet@po.cwru.edu GNU Bash-4.0 1998 July 30 BASHBUG(1)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy