I have a small but interesting task here. I have a list of files with same extension, for ex.
a.abc
b.abc
c.abc
What I want here is to first create folders called a, b, c… for each .abc file, and then move each one into its folder.
I was able to get the first step done pretty straightforwardly using a cmd line find ... | sed ... | xargs mkdir..., but when I tried to use a similar cmd to move each file into its own folder, I couldn’t find the answer.
I’m not fluent with the cmd here, and I have a very fuzzy memory that in find cmd I can use some kind of back reference to reuse the file/directory name, did I remember it wrong? Searched it up but couldn’t find a good reference.
Can anyone help me to complete the cmd here?
Thanks.
Here’s your one liner
or alternatively
And this is a better guide at using
findthan the man page.This page explains the parameter expansion that is going on (to understand the
${1%.*}