bash: command substitution: line 1: syntax error near unexpected token `^1'
bash: command substitution: line 1: `egrep(^1|3) file.txt | sed 's/ /,/''
---------- Post updated at 05:33 PM ---------- Previous update was at 05:28 PM ----------
It is working! Thanks a lot!
---------- Post updated at 06:33 PM ---------- Previous update was at 05:33 PM ----------
One additional question, is it possible to be done in a similar way if the line starts with string? E.g.
start something
one xxx yyy
two zzz xxx
three ccc vvv
four mmm nnn
stop something
one aaa bbb
two ccc ddd
three eee fff
four qqq www
start something
one rrr ttt
two yyy uuu
three iii ooo
four ppp sss
awk '
BEGIN{
num = "one two three four five six seven eight nine ten"
n = split(num,A)
for(i=1;i<=n;i++)NUM[A]=i
}
/start/,/stop/{
if ((NUM[tolower($1)]-2)^2 == 1)
printf "start,%s,%s,%s\n", $1, $2, $3
}
' file
awk '
BEGIN{
num = "one two three four five six seven eight nine ten"
n = split(num,A)
for(i=1;i<=n;i++)NUM[A]=i
}
/start/,/stop/{
if ((NUM[tolower($1)]-2)^2 == 1)
printf "start,%d,%s,%s\n", NUM[tolower($1)], $2, $3
}
' file