1

Is there a way to use apostrophes ' with the sed command?

I mean this: -

sed '-2 a\\
What's up?' text  

I am talking about the apostrophe in "What's up". If I do it like this it gives me an error "Unmatched"

I tried to escape that apostrophe with \ OR \\ like this What\'s up?, but it doesn't work.

1
  • 1
    and to use an apostrophe in, e.g., a search pattern you can use the octal: \o047 - e.g. sed -n -e '/\o047/p' to print only lines containing an apostrophe.
    – cas
    Commented Jul 3, 2016 at 13:46

1 Answer 1

2
sed '2 a\ 
What'\''s up?' text

or

sed "2 a\ 
What's up?" text

Not the answer you're looking for? Browse other questions tagged .