Hi all,
I'm trying to read in a character and use it as a separater on a string:
#!/bin/ksh
echo "Enter input line"
read input_header
echo "Enter separator:"
read separator
IFS="$separator" read -A fields <<< "$input_header"
for ((i=0;i<${#fields[@]};i++)) ; do
echo ${fields[$i]}
done
This works when using characters like comma's etc. But not with spaces and tabs:
-bash-4.1$ ./test.ksh
Enter input line
test1,test2,test3
Enter separator:
,
test1
test2
test3
-bash-4.1$ ./test.ksh
Enter input line
test1 test2 test3
Enter separator:
<- space
test1 test2 test3
Is there any way to do this?
Thanks