]> git.ipfire.org Git - people/stevee/pakfire.git/blob - tools/functions-lists
Cleanup database and add indexes.
[people/stevee/pakfire.git] / tools / functions-lists
1 #!/bin/bash
2
3 function listsort() {
4 local item
5 for item in $@; do
6 echo "${item}"
7 done | sort -u | tr "\n" " "
8 }
9
10 function listmatch() {
11 local arg=${1}
12 shift
13
14 local item
15 for item in $@; do
16 if [ "${arg}" = "${item}" ]; then
17 return 0
18 fi
19 done
20 return 1
21 }
22
23 function sort_by_length() {
24 local c
25 local i
26 for i in $@; do
27 echo "$(wc -c <<<${i}) ${i}"
28 done | sort -n -r | while read c i; do
29 echo "${i}"
30 done
31 }