1870 |
local filename="${file##*/}" |
local filename="${file##*/}" |
1871 |
local count |
local count |
1872 |
local output |
local output |
1873 |
|
local oldprotected |
1874 |
local i |
local i |
1875 |
|
local x |
1876 |
|
|
1877 |
declare -i count=0 |
# hack; do not honor a global set IFS like '§' |
1878 |
|
local IFS |
1879 |
|
|
1880 |
|
count=0 |
1881 |
|
|
1882 |
# check if there are already protected files |
# check if there are already protected files |
1883 |
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1884 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1885 |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1886 |
do |
do |
1887 |
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1888 |
done |
done |
1889 |
(( count ++ )) |
|
1890 |
|
# dirty hack to convert 0001 -> 1; 0120 -> 120 etc |
1891 |
|
x="${#count}" |
1892 |
|
for (( i=0; i<x; i++ )) |
1893 |
|
do |
1894 |
|
if [[ ${count:${i}:1} != 0 ]] |
1895 |
|
then |
1896 |
|
count="${count:${i}}" |
1897 |
|
break |
1898 |
|
fi |
1899 |
|
done |
1900 |
|
|
1901 |
|
count="${count}+1" |
1902 |
|
|
1903 |
# fill output up with zeros |
# fill output up with zeros |
1904 |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |