I'm trying replace a specific word read from a file with asterisks of the same length. Eg; cat -> *** snake -> *****
So, in my script below, it works in bash but not in ksh
for next in `cat $filename`; do
rep=${next//[^\"]/*}
echo "$next replace with $rep"
done;
Running it in ksh gives me a bad substitution error, Any ideas? Thanks
In older versions of ksh, you'll have to use the sed command:
for next in `cat $filename`; do
rep=$(print $next | sed 's/[^\"]/*/g')
echo "$next replace with $rep"
done;