Greetings all,
in an attempt to learn scripting, I decided that a good task would be to replace empty spaces in directory a folder names with underscores. So I am trying to find all sub-directories and files in the current directory. I am using the tutorial at www.shellscript.com, which has an example under Loops for2.sh, which allegedly loops through all files in a directory. Thus:
But it does not work. Any ideas?
Also, is there any other good tutorial?
Kindest regards,
M
in an attempt to learn scripting, I decided that a good task would be to replace empty spaces in directory a folder names with underscores. So I am trying to find all sub-directories and files in the current directory. I am using the tutorial at www.shellscript.com, which has an example under Loops for2.sh, which allegedly loops through all files in a directory. Thus:
Code:
# Find directories and files with spaces, replace with deesired character
#!/bin/sh
# Set protection
set -Cefu
# Define variables
SEARCH_DIRECTORY="/some_directory"
cd $SEARCH_DIRECTORY
# find and rename directories and files
for idx in *
do
if [ -d "$idx" ]
then
echo "Process directory "$idx""
else
echo "Process files in directory "$idx""
fi
done
But it does not work. Any ideas?
Also, is there any other good tutorial?
Kindest regards,
M