[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: awk not just using the Field separator as such. it is using the blank space as well ...



On 2/15/23, Greg Wooledge <greg@wooledge.org> wrote:
> If you want to read FIELDS of a SINGLE LINE as array elements, use
> read -ra:
>
> read -ra myarray <<< "$one_line"

 It didn't work. I tried different options. I am getting: "bash: read:
... : not a valid identifier"

 _PTH="83847547|2|dli.ernet.449320/449320-Seduction Of The Innocent_text.pdf"
 echo "// __ \$_PTH: \"${_PTH}\""

# read -ra -d "\\|" _PTH_AR <<< "${_PTH}"
# read -ra -d "\|" _PTH_AR <<< "${_PTH}"
# read -ra -d "|" _PTH_AR <<< "${_PTH}"

# read -ra -d '\\|' _PTH_AR <<< "${_PTH}"
# read -ra -d '\|' _PTH_AR <<< "${_PTH}"
# read -ra -d '|' _PTH_AR <<< "${_PTH}"

 _PTH_AR_L=${#_PTH_AR[@]}
 echo "// __ \$_PTH_AR_L: |${_PTH_AR_L}|, \"${_PTH}\""

 The reason why I use pipes as field delimiter is because it is an
excellent meta character when you are working with filesystems. Pipes
would not accepted for files or directory names for good reasons,
anyway.


Reply to: