You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: