LINUX.ORG.RU

История изменений

Исправление nexfwall, (текущая версия) :

[nexfwall@PCG31311V-LF02 ~]$ bash -x test
+ file=/tmp/tst
+ sep='$'
++ grep -o '$sep' /tmp/tst
grep: /tmp/tst: Нет такого файла или каталога
++ wc -l
+ num=0
+ echo 'Debug: num: [0]'
Debug: num: [0]
[nexfwall@PCG31311V-LF02 ~]$ cat test
#!/bin/bash -x
file='/tmp/tst'
sep='$'

num=$(grep -o "\\$sep" "$file" | wc -l)
echo "Debug: num: [$num]"

А что должно быть в /tmp/tst?

Исходная версия nexfwall, :

[nexfwall@PCG31311V-LF02 ~]$ bash -x test
+ file=/tmp/tst
+ sep='$'
++ grep -o '$sep' /tmp/tst
grep: /tmp/tst: Нет такого файла или каталога
++ wc -l
+ num=0
+ echo 'Debug: num: [0]'
Debug: num: [0]
[nexfwall@PCG31311V-LF02 ~]$ cat test
#!/bin/bash -x
file='/tmp/tst'
sep='$'

num=`grep -o "\\$sep" "$file"|wc -l` 
echo "Debug: num: [$num]"

А что должно быть в /tmp/tst?