Hello all im trying to achive some but for some stupid reason i don't get it what im doing wrong maybe some geek in bash can explain it for me
Thxx in advance
So my issue is
Code: Select all
#!/bin/bash
export SCRIPT_PATH="$(dirname $(readlink -f $0))"
export a="\\\[Desktop Entry\\\]"
export b="\\\[Desktop Action Window\\\]"
export c="\\\[Desktop Action Document\\\]"
export reg_1="(?s).*"
FP="${SCRIPT_PATH}/apps/sublime_text.desktop"
# LIKE THIS BOTH WAYS WORKS
line="\[Desktop Entry\](?s).*\[Desktop Action Window\](?s).*\[Desktop Action Document\](?s).*"
line="\[Desktop Entry\]${reg_1}\[Desktop Action Window\]${reg_1}\[Desktop Action Document\]${reg_1}"
grep -Poz "${line}" ${FP}
# using the loop it will not work
cnt=0
while read line ; do
if [ "$(sed -r "s/(.)/\1\n/g" <<< $line | sort | uniq | wc -l)" -eq 4 ] ; then
echo "linha => $line " # DEBUG LINE AND GIVES ME THE RIGHT OUTPUT
grep -Poz "$line" ${FP} # BUT ON THE OTHER HAND GREP WONT DISPLAY NUTTING
if [ ! -z "$( grep -oPz "`echo ${line}`" ${FP} )" ] ; then
echo "cnt = $cnt"
echo "cnt = $line"
fi
fi
cnt=$((cnt+1))
done <<<"$(echo -e {0..2}{0..2}{0..2}"\n")" | sed -r "s/0/${a}${reg_1}/ ; s/1/${b}${reg_1}/ ; s/2/${c}${reg_1}/"