-1

I was trying to play around with escape characters in aliases.

Here's a simple example : I want to create an alias for

echo 'Hello'

So I wrote the alias like below :

alias sample 'echo \'Hello\' '

But I see this when I try to source the alias :

Unmatched '.

Any idea why this could be happening?

PS : I know I can use alias "echo 'Hello'" , but I want to test out the escaping in aliases.

Any help is appreciated. Thanks!

1 Answers1

0

As noted in a comment above, your statement is missing the equals sign. However, consider using a Bash function instead, which are more flexible:

sample() {
    echo \'Hello\'
}

Felicia
  • 19