Friday, February 8, 2019

KornShell: Replace spaces with underscores

A simple ksh that will replace a space with "_"


#!/bin/ksh
find /your/file/directory -type f -name "* *" | \
while read file; do \
newfile="$(echo "$file" | sed 's/ /_/g')"
mv "${file}" "${newfile}"
done

No comments:

Post a Comment