I'm trying to move files from various 'docs' directories located inside a main 'DOCS' directory. For example, I want to move all the files from ~/DOCS/docs/* into ~/DOCS/* and then delete the now-empty 'docs' folder. I have over 1000 of these directories, each with different names, and some directories shouldn't change. Sorry if I'm being unclear!
2 Answers
If your 'docs' folder only contains regular files, you could simply run:
`mv $HOME/DOCS/docs/* $HOME/DOCS/ && rmdir $HOME/DOCS/docs`
But, if there are hidden files (like `.env` or `.gitignore`), try using:
`shopt -s dotglob nullglob && mv $HOME/DOCS/docs/* $HOME/DOCS/ && rmdir $HOME/DOCS/docs`
Just to note, `shopt` is specific to Bash and if you're using zsh, you'd type `mv $HOME/DOCS/docs/{*,.*} $HOME/DOCS/` to grab hidden files as well, but make sure to exclude `.` and `..`.
It sounds like you want to use the `mv` command. You can do it like this:
`mv -r ~/DOCS/docs/ ~/DOCS/`
Just remember that `mv` stands for move and `-r` means recursive, so it'll handle everything inside 'docs' and any subdirectories. This should work for your case!
Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux