Can you see what the problem or what went wrong with this file.sh , shel linux script. They show in the terminal when I run it : ./test.sh: line 70: syntax error: unexpected end of file. test.sh: while true; do case "$action" in "1") echo echo "<<-Lasses Logistik och Logik->>" cat data.txt echo "<<---End-of-file--->>" echo;; "2") echo "Sort the file by column: " echo "choose from below to sort" echo "i | n | v | l | b | h" read input ID_colnum=1 Name_column=2 Vikt_column=3 L_column=4 B_column=5 H_column=6 case $input in "i")head -n 1 data.txt && tail -n +2 data.txt | sort -k $ID_colnum;; "n")head -n 1 data.txt && tail -n +2 data.txt | sort -k $Name_column;; "v")head -n 1 data.txt && tail -n +2 data.txt | sort -k $Vikt_column;; "l")head -n 1 data.txt && tail -n +2 data.txt | sort -k $L_column;; "b")head -n 1 data.txt && tail -n +2 data.txt | sort -k $B_column;; "h")head -n 1 data.txt && tail -n +2 data.txt | sort -k $H_column;; "3") echo "Enter phone number to delete: " backup_files="data.txt" dest="/home/arwakhaddour/Documents/OPSY" day=$(date +%A) hostname=$(hostname -s) archive_file="$hostname-$day.tgz" echo "Backing up $backup_files to $dest/$archive_file" date echo tar czf $dest/$archive_file $backup_files echo echo "Backup finished" date echo;; "x") exit 0;; "X") exit 0;; esac echo "<< Lasses Logistik och Logik>>" echo echo "<1>. print the file " echo echo "<2>. Sort the file " echo echo "<3>. Backup" echo echo ". Exit program" echo echo "Enter your selection <1-3, x>:" read action esac data.txt: The textfile : ID Name Vikt L B H 012 Eric 56 156 7 13 045 Richard 78 178 9 17 098 Maya 60 164 10 16 072 Anna 56 152 8 14 034 Helena 76 169 11 18 022 Kevin 66 162 6 12 093 Peter 99 170 12 19
Can you see what the problem or what went wrong with this file.sh , shel linux script. They show in the terminal when I run it : ./test.sh: line 70: syntax error: unexpected end of file.
test.sh:
while true;
do
case "$action" in
"1") echo
echo "<<-Lasses Logistik och Logik->>"
cat data.txt
echo "<<---End-of-file--->>"
echo;;
"2") echo "Sort the file by column: "
echo "choose from below to sort"
echo "i | n | v | l | b | h"
read input
ID_colnum=1
Name_column=2
Vikt_column=3
L_column=4
B_column=5
H_column=6
case $input in
"i")head -n 1 data.txt && tail -n +2 data.txt | sort -k $ID_colnum;;
"n")head -n 1 data.txt && tail -n +2 data.txt | sort -k $Name_column;;
"v")head -n 1 data.txt && tail -n +2 data.txt | sort -k $Vikt_column;;
"l")head -n 1 data.txt && tail -n +2 data.txt | sort -k $L_column;;
"b")head -n 1 data.txt && tail -n +2 data.txt | sort -k $B_column;;
"h")head -n 1 data.txt && tail -n +2 data.txt | sort -k $H_column;;
"3") echo "Enter phone number to delete: "
backup_files="data.txt"
dest="/home/arwakhaddour/Documents/OPSY"
day=$(date +%A)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
tar czf $dest/$archive_file $backup_files
echo
echo "Backup finished"
date
echo;;
"x") exit 0;;
"X") exit 0;;
esac
echo "<< Lasses Logistik och Logik>>"
echo
echo "<1>. print the file "
echo
echo "<2>. Sort the file "
echo
echo "<3>. Backup"
echo
echo "<x>. Exit program"
echo
echo "Enter your selection <1-3, x>:"
read action
esac
data.txt:
The textfile :
ID Name Vikt L B H
012 Eric 56 156 7 13
045 Richard 78 178 9 17
098 Maya 60 164 10 16
072 Anna 56 152 8 14
034 Helena 76 169 11 18
022 Kevin 66 162 6 12
093 Peter 99 170 12 19
Step by step
Solved in 2 steps with 4 images