fish shell has powerful string modules.
The subcommands are lower
/ upper
, trim
, sub
(string), split
, join
, repeat
, length
, match
and so on.
Thus we can replace
strings via fish shell.
It's easy :)
The usage is:
$ string replace [(-a | --all)] [(-f | --filter)] [(-i | --ignore-case)] [(-r | --regex)] [(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
Besides, my current fish version is 3.0.2.
Well, for example, this is how to replace a file name with one that the size information is added to:
$ string replace -r "\.jpg\$" "\-360x.jpg" "some-file-name.jpg"
With iteration, it becomes more powerful 😉
$ for x in ./*.jpg; mv "$x" (string replace -ar "\.jpg\$" "\-360x.jpg" "$x"); end
This one-liner program renames files with a regular expression pattern via string replace
.
Top comments (0)