summaryrefslogtreecommitdiff
path: root/scripts/cli/nospac
blob: 414e68d49805b2a43cff716b13badb2747ac0908 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

. "lib_common.sh"

help() {
cat << EOF
${progname}: Replace all the spaces in file and directory
names with "_" in in the current directory.
options:
 -h              Print this message and exit
EOF
exit 0
}

[ "${1}" = "-h" ] && help

[ ${#} -gt 0 ] && invalid_use

for file in ./*; do
	newfile=$(echo "${file}" | tr ' ' '_')
	[ "${newfile}" != "${file}" ] && mv -v "${file}" "${newfile}"
done

exit 0