feature(archive) Add legacy personal executable repo
[BK-2020-03.git] / user / bkrandlujvo
CommitLineData
0d22dfcd
SBS
1#!/bin/bash
2# usage: bkrandlujvo
3
4INPUT_FILE="/home/baltakatei/Sync/kodawkuori-07/2020/reference-PERS/lojban/20190626..gismu_english_order.txt"
5if [ ! -f "$INPUT_FILE" ]; then echo "ERROR: gismu list text file not found." 2>&1 ; exit 1; fi
6
7randGismuDef () {
8 # usage: randGismuDef [gismu.txt file]
9 # output: <<gismu>>,<<def>>
10 FILE="$1"
11 randLineNum=$(shuf -n1 -i2-$(cat "$FILE" | wc -l)) # Generate random line number of FILE
12 # Output random 2nd space-delimted field (gismu) from file
13 #echo $(cat "$FILE" | cut -d' ' -f2-3 | head -n"$randLineNum" | tail -n1 )
14 echo $(cat "$FILE" | awk '{print $1 "," $3}' | head -n"$randLineNum" | tail -n1 )
15}
16
17randGismu () {
18 # usage: randGismu [gismu.txt file]
19 # output: <<gismu>>
20 FILE="$1"
21 randLineNum=$(shuf -n1 -i2-$(cat "$FILE" | wc -l)) # Generate random line number of FILE
22 # Output random 2nd space-delimted field (gismu) from file
23 echo $(cat "$FILE" | awk '{print $1}' | head -n"$randLineNum" | tail -n1 )
24}
25
26GISMU1=$(randGismu "$INPUT_FILE")
27GISMU2=$(randGismu "$INPUT_FILE")
28GISMU3=$(randGismu "$INPUT_FILE")
29
30#RAW1=$(randGismuDef "$INPUT_FILE")
31#RAW2=$(randGismuDef "$INPUT_FILE")
32#RAW3=$(randGismuDef "$INPUT_FILE")
33
34#GISMU1=$(echo "$RAW1" | cut -d',' -f1)
35#GISMU2=$(echo "$RAW2" | cut -d',' -f1)
36#GISMU3=$(echo "$RAW3" | cut -d',' -f1)
37
38#DEF1=$(echo "$RAW1" | cut -d',' -f2)
39#DEF2=$(echo "$RAW2" | cut -d',' -f2)
40#DEF3=$(echo "$RAW3" | cut -d',' -f2)
41
42echo "$GISMU1 $GISMU2 $GISMU3"
43#echo "$DEF1 $DEF2 $DEF3"
44
45if command -v jbofihe 1>/dev/null 2>&1; then
46 echo "$GISMU1" | jbofihe -x
47 echo "$GISMU2" | jbofihe -x
48 echo "$GISMU3" | jbofihe -x
49else
50 echo "ERROR: jbofihe command not available." 2>&1;
51fi
52
53if command -v jvocuhadju 1>/dev/null 2>&1; then
54 jvocuhadju "$GISMU1" "$GISMU2" "$GISMU3";
55else
56 echo "ERROR: jvocuhadju command not available." 2>&1;
57fi
58
59exit 0