Skip to main content
added 146 characters in body
Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k
perl -l -0777 -ne "print for /'''(.*?)'''/gs" file

would extract (and print followed by a newline) the part between each pair of '''.

Beware that perl slurps the whole file in memory before starting processing it so that solution may not be appropriate for very large files.

perl -l -0777 -ne "print for /'''(.*?)'''/gs" file

would extract (and print followed by a newline) the part between each pair of '''.

perl -l -0777 -ne "print for /'''(.*?)'''/gs" file

would extract (and print followed by a newline) the part between each pair of '''.

Beware that perl slurps the whole file in memory before starting processing it so that solution may not be appropriate for very large files.

Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

perl -l -0777 -ne "print for /'''(.*?)'''/gs" file

would extract (and print followed by a newline) the part between each pair of '''.