File: index.sh

package info (click to toggle)
libnss-cache 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: ansic: 1,701; makefile: 137; sh: 38
file content (21 lines) | stat: -rwxr-xr-x 529 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

in=$1
column=$2
out=$3

map=$(mktemp /tmp/libnss.XXXXXX)
strings -at d "$in" > "$map"
: > "$out"

exec 2>/dev/null
for value in $(tr -s [:blank:] ! < "$map" | cut -f3 -d! | cut -f"$column" -d: | LC_COLLATE=C sort) ; do
    offset=$(grep "$value" "$map" | tr -s [:blank:] ! | cut -f2 -d!)
    printf "%s\0%d\0" "$value" "$offset" >> "$out"
    len=$(printf "%s\0%d\0" "$value" "$offset" | wc -c)
    for _i in $(seq 1 $((16-len))) ; do 
        printf "\0" >> "$out"
    done
    printf "\n" >> "$out"
done
rm "$map"