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.

Michael Homer
  • 76,565
Anonymous
  • 287
  • 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 Jul 03 '16 at 13:46

1 Answers1

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

or

sed "2 a\ 
What's up?" text
steeldriver
  • 81,074