Assuming that you are in the same directory as your files:
for name in awstats.*.conf; do
basename "${name#awstats.}" .conf
done
The code inside the loop will first trim the awstats.
prefix off from $name
using a standard parameter substitution, and then lets basename
trim off the .conf
suffix.
You could also do it in two steps without calling basename
:
for name in awstats.*.conf; do
newname=${name#awstats.} # trim off prefix
newname=${newname%.conf} # trim off suffix
printf '%s\n' "newname"
done
No files are renamed by these two loops.
mv
commands. – Kusalananda Dec 18 '19 at 09:09rename
command? – FelixJN Dec 18 '19 at 09:17mv awstats.www.test1.com.conf www.test1.com
? I'm trying to figure out what your issue is. – Kusalananda Dec 18 '19 at 09:28rename
command looks odd. Please add this to your question in proper formatting. Regexes with two replacements would look like:s/A/B/;s/1/2/
---- @Kusalananda Pretty sure he is working on more than 3 files. – FelixJN Dec 18 '19 at 09:32