Reputation: 71
Long story short during execution, i noticed that the "*"
in the LIST somehow displays the name of the file i was executing. Is there anyway to let the code display "*"
instead of displaying the filename ?
I am still a script newbie, could not think of any way. Please help ...
#!/bin/bash
LIST='W 2 v * %'
encr="Cd9AjUI4nGglIcP3MByrZUnu.hHBJc7.eR0o/v0A1gu0/6ztFfBxeJgKTzpgoCLptJS2NnliZLZjO40LUseED/"
salt="8899Uidd"
for i in $LIST
do
for j in $LIST
do
for k in $LIST
do
for l in $LIST
do
for a in $LIST
do
echo -n "$i$j$k$l$a "
test=`mkpasswd -m SHA-512 $i$j$k$l$a -s $salt`
if [ $test == $encr ] ; then
echo " Password is: $i$j$k$l$a"
exit
fi
done
done
done
done
done
#error displaying *
Upvotes: 0
Views: 209
Reputation: 140880
The same as echo *
expands the globulation *
to the filenames in the current directory, the same way a=*; for i in $a; do echo $i; done
will print paths in the current directory. You can read more about quotes and escaping at various places in the net.
You can use bash arrays to correctly quotes elements:
LIST=(W 2 v "*" %)
for i in "${LIST[@]}"; do
Notes:
$(..)
instead.[ "$test" = "$encr" ]
to protect from common bugs like this.==
is a bash extension, use =
to be portable.echo {W,2,v,"*",%}{W,2,v,"*",%}{W,2,v,"*",%}{W,2,v,"*",%}{W,2,v,"*",%}
looks shorter.Upvotes: 2