Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /some/path/abcdefghi/abcdefghi - something - else/
  2.  
  3. /some/path/abcdefghi/something - else/
  4.  
  5. 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 {} ;
  6.  
  7. [vagrant@localhost test]$ mkdir -p SLUG_1/SLUG_{1 - SLUG_{2..4} - SLUG_5,7 - something}
  8. [vagrant@localhost test]$ find . -type d
  9. .
  10. ./SLUG_1
  11. ./SLUG_1/SLUG_1 - SLUG_2 - SLUG_5
  12. ./SLUG_1/SLUG_1 - SLUG_4 - SLUG_5
  13. ./SLUG_1/SLUG_1 - SLUG_3 - SLUG_5
  14. ./SLUG_1/SLUG_7 - something
  15. [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 {} ;
  16. [vagrant@localhost test]$ find . -type d
  17. .
  18. ./SLUG_1
  19. ./SLUG_1/SLUG_3 - SLUG_5
  20. ./SLUG_1/SLUG_4 - SLUG_5
  21. ./SLUG_1/SLUG_2 - SLUG_5
  22. ./SLUG_1/SLUG_7 - something
  23. [vagrant@localhost test]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement