From 8c36d69ca6ed2dc74efd6563e559ac606fc06a48 Mon Sep 17 00:00:00 2001 From: JimboKearn Date: Fri, 18 Jun 2021 09:47:47 +0530 Subject: [PATCH] replaced awk and cut with sed --- ani-cli | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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