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
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