Skip to main content
-0 is for NUL delimited records, -0777 to slurp.
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k
perl -0ne0777 -ne 'print sort /(#+[^#]*)/g' file.txt
  • perl -00777 -n slurps the entire file (see also perl -gn in newer versions of perl).
  • /(....)/g match and extract the records
  • print sort ... sort and print them
perl -0ne 'print sort /(#+[^#]*)/g' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
perl -0777 -ne 'print sort /(#+[^#]*)/g' file.txt
  • perl -0777 -n slurps the entire file (see also perl -gn in newer versions of perl).
  • /(....)/g match and extract the records
  • print sort ... sort and print them
edited body
Source Link
JJoao
  • 12.8k
  • 1
  • 26
  • 45
perl -0ne 'print sort /(#*[^#]*#+[^#]*)/g' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
perl -0ne 'print sort /(#*[^#]*)/g' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
perl -0ne 'print sort /(#+[^#]*)/g' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
deleted 1 character in body
Source Link
JJoao
  • 12.8k
  • 1
  • 26
  • 45
perl -0ne 'print sort /(#*[^#]*)/gs'g' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
perl -0ne 'print sort /(#*[^#]*)/gs' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
perl -0ne 'print sort /(#*[^#]*)/g' file.txt
  • perl -0 slurps the entire file
  • /(....)/g match and extract the records
  • print sort ... sort and print them
Source Link
JJoao
  • 12.8k
  • 1
  • 26
  • 45
Loading