tags:

views:

197

answers:

2

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
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
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
A: 

you can use the octal value of SOH as a delimiter using awk.

$ awk -F"\001" '{print $1}' file
ghostdog74