![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to find a file named vijay in a directory using find command | amirthraj_12 | UNIX for Dummies Questions & Answers | 6 | 10-25-2008 01:37 PM |
| Unix command for Watermark printing | meeraramanathan | SUN Solaris | 1 | 05-30-2008 02:30 AM |
| Little bit weired : Find files in UNIX w/o using find or where command | jatin.jain | Shell Programming and Scripting | 10 | 09-19-2007 07:47 AM |
| command find returned bash: /usr/bin/find: Argument list too long | yacsil | Shell Programming and Scripting | 1 | 12-15-2003 06:38 PM |
| how to find a file in UNIX without find command? | bluo | Shell Programming and Scripting | 3 | 09-25-2003 12:47 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to find watermark in a pdf
Hi All,
I have a few pdf files some of which have a watermark on it and my task is to find which all invoices have watermark without actually printing them. Is there any way we can do this in Unix. Strings is not helping. any idea how would I read binary file and grep for watermark. The watermark has a text "XYZ" Regards... |
|
||||
|
pdf files can be in compressed format, so this may not help at all, and depending on the pdf engine the X Y and Z can be separate: Code:
for file in *.pdf do grep -l '(XYZ)Tj$' $file done You could also try: Code:
for file in *.pdf
do
if [[ `grep -q '(X)Tj$' $file` ]] ; then
if [ `grep -q '(Y)Tj$' $file` ]] ; then
if [[ `grep -q '(Z)Tj$' $file` ]] ; then
echo "$file"
fi
fi
fi
done
This last one is an EXTREMELY inefficient method.... but is usually the way watermarks are generated. One char at a time. |
|
||||
|
thanks for your answer. Could you explain how does '(X)Tj$' work. pdf is a binary file isn't it. on my version it is giving following error:
grep: illegal option -- q Usage: grep -hblcnsviw pattern file . . . it is Sun 5.10 Regards,. Rahul |
|
||||
|
figures.. Solaris 5.10 isn't close to POSIX...
grep -q is the 'silent' way to look for a pattern it suppreses the display, but returns a status value ($?) to indicate whether it succeeded or not. See if one of your options does that. ( stuff in here )Tj is the way a postscript ()show command is written to uncompressed pdf format files. This displays "stuff in here". '(X)Tj$' is the pattern for the command to print a single character 'X'. Again in uncompressed format. If you literally cannot read your pdf because it is full of really weird characters, then it is compressed and this method will not work. |
|
||||
|
Instead of -q on Solaris you can just do: Code:
grep value file >/dev/null Just use the exit status from grep in your if. (0 = match found, 1 = no match). So in your code it'd be like: Code:
if [[ `grep '(X)Tj$' $file >/dev/null` ]] ; then And so on... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|