Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Currently, option rename 's/_/-/g; s/\A-*//' * works best for me. But, can you explain in short how to skip detox and replace not underscores, but spaces with dashes with this command? I don't understand it's structure, so I don't know how to change it. Commented Apr 19, 2015 at 12:57
  • @IgorVuckovic s/PATTERN/REPLACEMENT/ replaces PATTERN (a Perl regular expression) by REPLACEMENT. The g suffix means to replace all occurrences (without it, only the first is replaced). For example s/_/-/g replaces each _ by a -. s/[^[:alnum:]]/-/ replaces each non-alphanumeric character by a -. s/[^[:alnum:]]+/-/ replaces each sequence of non-alphanumeric characters by a single -. s/ +/-/ replaces each sequence of spaces by a -. A \A at the beginning of the pattern means that the replacement is carried out at the beginning of the name only. Commented Apr 19, 2015 at 13:02