Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

remove pdf last list

#!/bin/sh
IN="$1"
filename=$(basename "${IN}")
filename="${filename%.*}"
PAGES=$(pdfinfo "$IN" | grep ^Pages: | tr -dc '0-9')
  
non_blank() {
    for i in $(seq 1 $PAGES)
    do
        PERCENT=$(gs -o -  -dFirstPage=${i} -dLastPage=${i} -sDEVICE=inkcov "$IN" | grep CMYK | nawk 'BEGIN { sum=0; } {sum += $1 + $2 + $3 + $4;} END { printf "%.5f
", sum } ')
        if [ $(echo "$PERCENT > 0.001" | bc) -eq 1 ]
        then
            echo $i
            #echo $i 1>&2
        fi
        echo -n . 1>&2
    done | tee "${DIR}/$filename.tmp"
    echo 1>&2
}
  
set +x
pdftk "${IN}" cat $(non_blank) output "${filename}_copy.pdf"
Comment

PREVIOUS NEXT
Code Example
Shell :: setup git on windows 
Shell :: how to copy a file in linux 
Shell :: copy data to kubernetes pod 
Shell :: getting error while installing npm react-redux-form 
Shell :: unzip recursively linux 
Shell :: how to install aiohttp on vscode 
Shell :: git fetch upstream from master 
Shell :: proxy shell 
Shell :: python alias 
Shell :: powershell tcp reverse shell 
Shell :: deleting index.lock 
Shell :: fatal pathspec is in submodule 
Shell :: bash add extension to all files 
Shell :: git ignore files 
Shell :: setup cron job 
Shell :: create public and private key for jwt 
Shell :: recursively change file permissions linux 
Shell :: git new branch from current 
Shell :: linux history delete line 
Shell :: windows install composer 
Shell :: Installing Command line tools for Xcode via CLI 
Shell :: material-ui 
Shell :: upload local to remote ssh 
Shell :: ubuntu change /etc/resolv.conf 
Shell :: docker compose limit logs 
Shell :: cannot find mui lab module 
Shell :: bash: ./runapp.sh: Permission denied 
Shell :: configurer kdiff3 
Shell :: add directory to path on linux 
Shell :: merge last three commits squash 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =