Roger
Roger

Reputation: 29

How to move certain directories under few parent directories one level up in unix

I have

A/1/a
A/1/b

B/1/a
B/1/b

all these are folders. I am trying to move the directories so that it may look like

A/a
A/b

B/a
B/b

I am sure I should use mv command but I am not sure to do it for all the directories at once.

Upvotes: 0

Views: 28

Answers (1)

Jens
Jens

Reputation: 72639

Not in one go, but since we're not code golfing:

 mv A/1/* A; rmdir A/1
 mv B/1/* B; rmdir B/1

The canonical gotchas apply, like * not globbing dot files, depending on shell options. You'll know when you run into them when you see rmdir: directory not empty.

Upvotes: 1

Related Questions