0

Let's consider the following recfile

Name: John
Text: It's me!

Name: Jane Text: Hello

The following command works perfectly to select the second record

recsel -e "Text = 'Hello'" test.rec

but how to select the first one?

recsel -e "Text = 'It\'s me!'" test.rec

is not working even if according the documentation (section 3.5.2.2 String Literals) it's the correct syntax.

I am using GNU Recutils version 1.9.

1 Answers1

0

This is really a matter of shell quoting rather than recsel specifically.

The ! in your record text adds an extra complication (at least in an interactive bash shell) - without it, you could use escaped double quotes within double quotes, which remove the special meaning of any single quotes inside. Turning off history expansion to demonstrate:

$ set +o histexpand
$ recsel -e "Text = \"It's me!\"" test.rec
Name: John
Text: It's me!

Otherwise, you can use outer single quotes, closing and reopening them around the literal single quote:

$ recsel -e 'Text = "It'\''s me!"' test.rec
Name: John
Text: It's me!
steeldriver
  • 81,074