-
Notifications
You must be signed in to change notification settings - Fork 170
Open
Description
I have a .sh script that I made myself but my boss uses Windows, I'd like to rewrite this in batsh but, HOW CAN I READ INPUTS FROM USER?
There's a function for that? I couldn't find any reference for this.
This is the bash code:
#!/bin/bash
echo "Digite a pasta: ";
read dir;
nome="";
for i in $(ls "${dir}"); do
if [[ ! -d "${dir}/${nome}" || -z $nome ]] ; then
nome+="${i}";
if [ ! -d "${dir}/${nome}" ]; then
nome+=" ";
fi;
fi;
if [ -d "${dir}/${nome}" ] ; then
nomenovo="";
for subnome in $nome; do
if [[ $subnome =~ ^[0-9]+$ ]] ; then
subnome=$(seq -f "%05g" ${subnome} ${subnome});
fi
nomenovo="$nomenovo $subnome";
done
echo "NOME ANTIGO: ${nome}"
echo "NOME NOVO: ${nomenovo}";
echo
echo "-------------------"
cp -r "${dir}/${nome}" "${dir}/${nomenovo}";
nome="";
fi;
done
Metadata
Metadata
Assignees
Labels
No labels