diff --git a/ani-cli b/ani-cli index aea317b..c567283 100755 --- a/ani-cli +++ b/ani-cli @@ -134,7 +134,7 @@ shift $((OPTIND - 1)) if [ $resume_watching -eq 0 ]; then search_results=$(search_anime "$query") else - search_results=$(cut -f1 $logfile) + search_results=$(sed -n -E 's/\t[0-9]*//p' $logfile) fi [ -z "$search_results" ] && die "No search results found" @@ -195,7 +195,7 @@ if [ $resume_watching -eq 0 ]; then read ep_choice_start ep_choice_end printf "$c_reset" else - ep_choice_start=$(awk "/${selection_id}/ { print \$2 }" $logfile) + ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" $logfile) fi { # checking input @@ -237,8 +237,8 @@ open_episode () { if [ $is_download -eq 0 ]; then # write anime and episode number if $(grep -w "${selection_id}" $logfile >/dev/null); then - awk -F'\t' " - BEGIN {OFS=\"\\t\"}; NR != $choice; NR == $choice { \$2=$((episode+1));print } + sed -E " + s/^${selection_id}\t[0-9]+/${selection_id}\t$((episode+1))/ " $logfile > "${logfile}.new" && mv "${logfile}.new" $logfile else printf "%s\t%d\n" "$selection_id" $((episode+1)) >> $logfile