-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectElements.sh
More file actions
executable file
·25 lines (20 loc) · 901 Bytes
/
selectElements.sh
File metadata and controls
executable file
·25 lines (20 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/zsh
OUTPUT_FILE="output.xml"
TEMP_FILE="output_tmp.xml"
NODES_FILE="output_subelements.txt"
echo "<root>" > "$TEMP_FILE"
echo "🔍 Searching for .storyboard files..."
find ./Project -name "*.storyboard" -print0 | while IFS= read -r -d '' file; do
echo "Processing: $file..."
xmlstarlet sel --omit-decl -t -m '//viewController' -c "." -n "$file" >> "$TEMP_FILE"
done
echo "</root>" >> "$TEMP_FILE"
# Delete <subviews> from each root-level element (children of <root>)
xmlstarlet ed -d '/root/*/subviews' "$TEMP_FILE" | xmlstarlet fo > "$OUTPUT_FILE"
# Extract unique set of first-level node names under <root>
#xmlstarlet sel -t -m '/root/*/*' -v 'name()' -n "$TEMP_FILE" | sort -u > "$NODES_FILE"
xmlstarlet sel -t -m '/root/*/*' \
-v 'name()' -o ' ' -v '@key' -n "$OUTPUT_FILE" \
| sort | uniq -c | sort -nr > "$NODES_FILE"
#rm "$TEMP_FILE" # Clean up temporary file
echo "Done"