Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /some/path/abcdefghi/abcdefghi - something - else/
- /some/path/abcdefghi/something - else/
- find . -mindepth 2 -maxdepth 2 -type d -regextype posix-egrep -regex '.*/([^/]+)/1[^/]+' -exec sh -c 'new="$(sed -r "s:/([^/]+)/\1 ?-? ?([^/]+)$:/\1/\2:" <<<$1)"; mv "$1" "$new"' find-sh {} ;
- [vagrant@localhost test]$ mkdir -p SLUG_1/SLUG_{1 - SLUG_{2..4} - SLUG_5,7 - something}
- [vagrant@localhost test]$ find . -type d
- .
- ./SLUG_1
- ./SLUG_1/SLUG_1 - SLUG_2 - SLUG_5
- ./SLUG_1/SLUG_1 - SLUG_4 - SLUG_5
- ./SLUG_1/SLUG_1 - SLUG_3 - SLUG_5
- ./SLUG_1/SLUG_7 - something
- [vagrant@localhost test]$ find . -mindepth 2 -maxdepth 2 -type d -regextype posix-egrep -regex '.*/([^/]+)/1[^/]+' -exec sh -c 'new="$(sed -r "s:/([^/]+)/\1 ?-? ?([^/]+)$:/\1/\2:" <<<$1)"; mv "$1" "$new"' find-sh {} ;
- [vagrant@localhost test]$ find . -type d
- .
- ./SLUG_1
- ./SLUG_1/SLUG_3 - SLUG_5
- ./SLUG_1/SLUG_4 - SLUG_5
- ./SLUG_1/SLUG_2 - SLUG_5
- ./SLUG_1/SLUG_7 - something
- [vagrant@localhost test]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement