I have multiple filenames that look something like;
com.test.app1.deb
com.heavy.test.app2.deb
com.maybe-test.app3.deb
com.crazy.app-4.deb
I would like to get the bolded strings only.
so far, I’ve got this,
name=$(echo $file | sed 's!\(*.\)\(.*\).deb!\2!')
EDIT:
I have other files in the same dir that would name something like;
com.company.name_1.0.2_arm.deb
Currently, my code looks like;
for file in *.deb; do
name=$(echo "$file" | sed 's/^.*\.\([^.][^.]*\)\.deb$/\1/')
echo $name
done
You want negative matching so you can exclude dots from the part of the string that you want to capture. I also anchored the string so that you don’t get a nasty surprise on a name like
com.deboop.foo.deb.(edited to reflect comments)