JQ — Список всех ключей, кроме массивов

#!/bin/bash
# prepare files
home="/home/exchange"
cd $home
>acl
echo "#!/bin/bash">recovery_acl.sh
echo "cd $home">>recovery_acl.sh
f='./'
# create acl file sorted by dir_level
for i in `seq 0 15`;do
  find. -mindepth $i -maxdepth $i -type d -exec getfacl {} +|grep -E '*UTS|file:'>>acl
done
sed -i 's/default\:user/\-dm\ u/g' acl
sed -i 's/default\:group/\-dm\ g/g' acl
sed -i 's/user/\-m\ u/g' acl
sed -i 's/group/\-m\ g/g' acl
sed -i 's/\#\ file\:\ /\.\//g' acl
sed -i 's,\\,\\\\,g' acl

while IFS='' read -r line ; do
  # grep dir name
  if echo "$line" | grep -q "$f" ; then
    dir="$line"
    continue
  fi
  echo setfacl $line '"'$dir'"'>>recovery_acl.sh
  # grep non def acl (for files)
  if echo "$line" | grep -q '\-m' ; then
    echo setfacl $line '"'$dir'"'/*>>recovery_acl.sh
  fi
done < "acl"

sed -i "s/\\\134/\\\\\\\134/g" recovery_acl.sh
sed -i "s/\\\040/\\\\ /g" recovery_acl.sh

Этот скрипт bash получает только каталоги acl (в моем случае files acls = dir (parent )acl )После выполнения скрипта будет создан еще один "recovery _acl.sh".

При восстановлении ошибки типа «Нет такого файла или каталога» означают, что каталог пуст или имя каталога содержит два или более пробелов вместе.

1
30.10.2019, 20:59
1 ответ

это работает:

jq -r 'paths(scalars) | map(.|tostring)|join(".")' weather.json

результат

coord.lon
coord.lat
weather.0.id
weather.0.main
weather.0.description
weather.0.icon
base
main.temp
main.pressure
main.humidity
main.temp_min
main.temp_max
visibility
wind.speed
wind.deg
rain.1h
clouds.all
dt
sys.type
sys.id
sys.country
sys.sunrise
sys.sunset
timezone
id
name
cod
0
27.01.2020, 23:40

Теги

Похожие вопросы