dev/endpoints/get-fields.sh
2024-02-20 10:30:02 +02:00

33 lines
569 B
Bash
Executable File

#!/bin/bash
#
# example:
#
# ./get-fields.sh klimatologia4 node edition
#
# body text_with_summary
# field_author string
# field_file file
#
IFS=$'\n'
SITE_DIR=$1
TYPE=$2
NAME=$3
cd /var/www/sites/$SITE_DIR
for FIELD in $(../vendor/drush/drush/drush fi ${TYPE} ${NAME} | tail -n +3 | grep -v '\-\-\-'); do
NAME=$(echo $FIELD | awk '{print $1}')
TYPE=$(echo $FIELD | awk '{print $2}')
COUNT=$(echo $TYPE | wc -c)
THIRD=$(echo $FIELD | awk '{print $3}')
if [ "$COUNT" -lt 5 ] && [ -z "${SECOND// }" ]; then
TYPE=$THIRD
fi
echo "$NAME $TYPE"
done