Sponsored Content
Top Forums Shell Programming and Scripting problem with echo inserting single quotes Post 302451866 by jelloir on Wednesday 8th of September 2010 09:46:16 AM
Old 09-08-2010
I can't seem to get this to work.

I am using the following...

Code:
#!/bin/bash

exclude='Archive PST,SystemState'

echo "${exclude}" | tr ',' '\n' | while read exclusion
do
        rsyncExclusions="${rsyncExclusions} --exclude=\"${exclusion}\""
done

echo "$rsyncExclusions"
rsync -avh --delete --delete-excluded "$rsyncExclusions" /tmp/test1 /tmp/test2

This is the output:

Code:
$ bash -x /tmp/exclude 
+ exclude='Archive PST,SystemState'
+ echo 'Archive PST,SystemState'
+ tr , '\n'
+ read exclusion
+ rsyncExclusions=' --exclude="Archive PST"'
+ read exclusion
+ rsyncExclusions=' --exclude="Archive PST" --exclude="SystemState"'
+ read exclusion
+ echo ''

+ rsync -avh --delete --delete-excluded '' /tmp/test1 /tmp/test2
sending incremental file list
./
.viminfo

sent 11.85K bytes  received 40 bytes  23.77K bytes/sec
total size is 165.35K  speedup is 13.91

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem with single quotes in a string and findbug

I'm having trouble manipulating a string that contains single quotes (') in it. I'm writing a ksh script to parse in a few queries from a config file, such as this: findbug \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class... (9 Replies)
Discussion started by: bob122480
9 Replies

2. Shell Programming and Scripting

echo using single quotes

Hi, Please help me to echo the following statement using single quotes Why can't I write 's between single quotes Thanks in advance, Chella (3 Replies)
Discussion started by: chella
3 Replies

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

4. Shell Programming and Scripting

Problem renaming a file with single quotes

Hi, I am trying to create a script which validates the incoming source files. The script has File name Pattern as Argument. The First part of the script validates if there are any files available if then echo "\n Files are available to process \n" else echo "\n File does not... (9 Replies)
Discussion started by: dsshishya
9 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. UNIX for Dummies Questions & Answers

awk for inserting a variable containing single and double quotes

Hi i have to insert the below line into a specific line number of another file export MBR_CNT_PRCP_TYPE_CODES_DEL="'01','02','04','05','49','55','UNK'" I have passed the above line to a variable say ins_line. I have used below command to perform the insert awk 'NR==3{print "'"${ins_line}"'"}1'... (1 Reply)
Discussion started by: sathishteradata
1 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
Test::CheckManifest(3pm)				User Contributed Perl Documentation				  Test::CheckManifest(3pm)

NAME
Test::CheckManifest - Check if your Manifest matches your distro VERSION
version 1.25 SYNOPSIS
use Test::CheckManifest; ok_manifest(); DESCRIPTION
"Test::CheckManifest" EXPORT There is only one method exported: "ok_manifest" METHODS
ok_manifest [{exclude => $arref}][$msg] checks whether the Manifest file matches the distro or not. To match a distro the Manifest has to name all files that come along with the distribution. To check the Manifest file, this module searches for a file named "MANIFEST". To exclude some directories from this test, you can specify these dirs in the hashref. ok_manifest({exclude => ['/var/test/']}); is ok if the files in "/path/to/your/dist/var/test/" are not named in the "MANIFEST" file. That means that the paths in the exclude array must be "pseudo-absolute" (absolute to your distribution). To use a "filter" you can use the key "filter" ok_manifest({filter => [qr/.svn/]}); With that you can exclude all files with an '.svn' in the filename or in the path from the test. These files would be excluded (as examples): o /dist/var/.svn/test o /dist/lib/test.svn You can also combine "filter" and "exclude" with 'and' or 'or' default is 'or': ok_manifest({exclude => ['/var/test'], filter => [qr/.svn/], bool => 'and'}); These files have to be named in the "MANIFEST": o /var/foo/.svn/any.file o /dist/t/file.svn o /var/test/test.txt These files not: o /var/test/.svn/* o /var/test/file.svn EXCLUDING FILES
Beside "filter" and "exclude" there is another way to exclude files: "MANIFEST.SKIP". This is a file with filenames that should be excluded: t/my_very_own.t file_to.skip ACKNOWLEDGEMENT
Great thanks to Christopher H. Laco, who did a lot of testing stuff for me and he reported some bugs to RT. AUTHOR
Renee Baecker, <module@renee-baecker.de> COPYRIGHT AND LICENSE
Copyright (C) 2006 - 2011 by Renee Baecker This library is free software; you can redistribute it and/or modify it under the same terms as Artistic License 2.0 AUTHOR
Renee Baecker <module@renee-baecker.de> COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Renee Baecker. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.14.2 2012-01-31 Test::CheckManifest(3pm)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy