/ Published in: Bash
This command line aims at moving directories from a target location to the present working directory (pwd), backing the pwd directories up as it encounters them.
The script works by:
Iterating through the contents of the target directory (using the unix ls command)
Checking whether the current object is a directory
Moving the pwd directory to a backup location using the unix mv command
Moving the target location's directory to the present working directory
Printing out the modified directory's name using the unix echo command
Expand |
Embed | Plain Text
for subdir in `ls targetDir`; do if [ -d "$subdir" ]; then mv "$subdir" "backup/$subdir"; mv "targetDir/$subdir" "$subdir"; echo "$subdir"; fi; done
You need to login to post a comment.
