How to replace spaces with -(dash) from directory name in Linux using command line?
Note: There are hundreds of directories and all of them have sub directories too.
I have tried below command but it return a message 'call: rename from to files...' and all names are still unchanged.
find /home/jjj/ddd -name "* *" -type d | rename 's/ /-/g'
I would like Change the " Directory Name " to " Directory-Name ".
You can try using shell instead rename
find /home/jjj/ddd -depth -name "* *" -type d -print0 | while read -d $'\0' dir; do mv -v "$dir" "${dir// /-}"; done
added
-depth
to make it proper as per requirement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.