replaced awk and cut with sed

This commit is contained in:
JimboKearn 2021-06-18 09:47:47 +05:30
parent 22f223a4ec
commit 8c36d69ca6

View File

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