I found this command perl -ne 'print $1 if m/\.([^.\/]+)$/' and I'd be very grateful if someone familiar with perl could tell me in a nutshell what exactly all the syntax means, it would save a lot of time trying to look this all up by myself.

Thanks a lot!

closed as off-topic by Anthon, Archemar, Jeff Schaller, Jakuje, user79743 Mar 7 '16 at 17:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – Anthon, Archemar, Jeff Schaller, Jakuje, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

  • -n reads the input line by line.
  • [^.\/] is a character class, it matches everything except for a dot and slash.
  • + means the character should appear at least once.
  • \. matches a dot.
  • $ matches the end of string.
  • (...) creates a capture group.
  • the whole m/.../ thing is a regular expression match, it matches a dot followed by non-dots and non-slashes until the end of the string. The non-dot-non-slash part is remembered in $1.
  • If there was a match, it's printed.
  • And the -e in -ne? Anyways, thanks a lot! You saved me hours of trying to look this all up : ) – Daeto Mar 7 '16 at 17:24
  • -e just indicates the code itself follows. Instead of a "thank you", you can upvote/accept the answer. – choroba Mar 7 '16 at 17:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.