Maybe if I write this down I will actually remember next time
uses parameter expansion
quick:
${var#pattern}
shortest prefix pattern trim, ##
for longest${var%pattern}
shortest suffix pattern trim, %%
for longest${var/pattern/repl}
replace 1st pattern with repl${var//pattern/repl}
replace all pattern with repl1for f in *.txt; do
2 mv $f "${f%txt}md"
3done
4
5# or with find for more precise targeting
6find . -name '*.txt' -exec sh -c 'f={}; mv $f ${f%txt}md'
a zsh module in other functions
()
to capture for reference with $n
(a variable where parameter expansion can be applied)$f
for filename1zmv '(*).txt' '$1.md'
the one that comes with util-linux
on Arch,
takes a pattern and what to replace it with and some files,
super undocumented
1rename md txt *
basically sed for file names
1perl-rename 's/(.*).md/\1.txt/' *