chore(config-shared): Remove syncthing instructions
[BK-2020-03.git] / user / bkrandlujvo
1 #!/bin/bash
2 # usage: bkrandlujvo
3
4 INPUT_FILE="/home/baltakatei/Sync/kodawkuori-07/2020/reference-PERS/lojban/20190626..gismu_english_order.txt"
5 if [ ! -f "$INPUT_FILE" ]; then echo "ERROR: gismu list text file not found." 2>&1 ; exit 1; fi
6
7 randGismuDef () {
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
17 randGismu () {
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
26 GISMU1=$(randGismu "$INPUT_FILE")
27 GISMU2=$(randGismu "$INPUT_FILE")
28 GISMU3=$(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
42 echo "$GISMU1 $GISMU2 $GISMU3"
43 #echo "$DEF1 $DEF2 $DEF3"
44
45 if command -v jbofihe 1>/dev/null 2>&1; then
46 echo "$GISMU1" | jbofihe -x
47 echo "$GISMU2" | jbofihe -x
48 echo "$GISMU3" | jbofihe -x
49 else
50 echo "ERROR: jbofihe command not available." 2>&1;
51 fi
52
53 if command -v jvocuhadju 1>/dev/null 2>&1; then
54 jvocuhadju "$GISMU1" "$GISMU2" "$GISMU3";
55 else
56 echo "ERROR: jvocuhadju command not available." 2>&1;
57 fi
58
59 exit 0