I was trying to enumerate a bunch of files in bash and noticed the following strange error occuring.
The input string 'rtpwatcher_Class_Sync_License_Capture' gets echo'd as 'rtpwatcher_Class_ ync_ icense_Capture', seemingly removing uppercase characters at random.
Code:
hb_names=("rtpwatcher_Truckmove_Statemachine" "rtpwatcher_Class_Sync_License_Capture")
hb_test="rtpwatcher_Truckmove_Statemachine,rtpwatcher_Class_Sync_License_Capture"
for i in $(echo $hb_test | tr ',' '\n')
do
echo $i
done
for hb in ${hb_names[@]}; do
echo $hb
done
Output:
rtpwatcher_Truckmove_ tatemachine
rtpwatcher_Class_ ync_ icense_Capture
rtpwatcher_Truckmove_ tatemachine
rtpwatcher_Class_ ync_ icense_Capture
I've tried changing the string to only have one upper case character (rtpwatcher_Class_sync_license_capture) and the output was 'rtpwatcher_Class_sync_license_capture' as expected.
SOLVED:
for hb in "${hb_names[@]}"; do
echo "${hb}"
done