Skip to content

Single Quotes in Shell Script Compilation Error #2539

Answered by manuelesimi
gouinK asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

See if the following helps (it works for me):

process Test {

    output:
    path("QS_matches.txt")

    shell:
    '''
    echo '!"#$%&'"'""'""'"'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[]^_`abcdefghijklmnopqrstuvwxyz{|}~' | fold -w 1 > QS_matches.txt
    '''
}

This is the content of the output file:

!
"
#
$
%
&
'
'
'
(
)
*
+
,
-
.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
[
]
^
_
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~

I exploited the capability offered by Bash to glue both kinds of quotations (single and double) and then used "'" to quote each single quote inside your string.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bentsherman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2538 on January 05, 2022 22:15.