How do I split a line of text in bash using SOH delimiter?
A:
You can set the IFS variable to change the delimiter between words. (Don't forget to save the old value so you can restore it when you're done.)
Based on a quick google I assume "SOH delimiter" is the character with code 1, so you need to get that odd character into IFS:
IFS=`echo -e '\01'`
If that's not enough, you probably need to expand on "split a line of text". What do you want to split it into?
Andy Mortimer
2010-04-08 18:50:44
You don't need to use `echo` you can do this `IFS=$'\1'`. Also `man ascii` will give you a table that shows the names of character codes.
Dennis Williamson
2010-04-08 20:25:05
I want to split it so that it will make up the members of an array.IFS=`echo -e '\01'` read -ra VAL_ARR <<< "$val"It still doesn't quite work. I also tried:IFS=$'\1' read -ra VAL_ARR <<< "$val"
syker
2010-04-08 20:48:09
A:
you can use the octal value of SOH as a delimiter using awk.
$ awk -F"\001" '{print $1}' file
ghostdog74
2010-04-09 00:14:04