Использование sed в очень простом ограниченном подходе:
# Utility functions: print-as-echo, print-line-with-visual-space.
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
pl " Input data file $FILE:"
head $FILE
pl " Input data file $FILE, invisibles marked:"
cat -A $FILE
pl " Results:"
sed -e 's/[ ]*&&[ ]*/\n/g' -e 's/[ ]*||[ ]*/\n/g' $FILE
производство:
-----
Input data file data2:
one-space && next-one || last-one
one-TAB && next-tab || last-tab
mixed-tabs-space && next-mixed || last-mixed
-----
Input data file data2, invisibles marked:
one-space && next-one || last-one$
$
one-TAB^I&&^Inext-tab^I||^Ilast-tab$
$
mixed-tabs-space ^I && ^I^Inext-mixed^I || ^Ilast-mixed$
-----
Results:
one-space
next-one
last-one
one-TAB
next-tab
last-tab
mixed-tabs-space
next-mixed
last-mixed
В системе типа:
OS, ker|rel, machine: Linux, 3.16.0-7-amd64, x86_64
Distribution : Debian 8.11 (jessie)
sed (GNU sed) 4.2.2
[] заключает в себе TAB и пробел, поэтому разрешено любое количество таких белых -пробелов. Это не учитывает строки в кавычках и т. д.
С наилучшими пожеланиями... ура, дрл