|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|||
run same command many times with diff args
Hello
I need to delete some pages from quite a few .djvu files. The problem is the djvm command only accepts one page, no page ranges. So, how do I run the same command but increasing by one every time until a certain number? The djvm command looks like this: Code:
djvm -d file.djvu pagenumber |
|
|||
thanks DutchDaemon.
Actually, now that I think of it, I could simply run the same program 10 times, since the pages I need to delete are all at the beginning of the file. But learned something new, which is good |
|
|||
uhm, actually, I've tried your command, but it does not seem to do the job
|
|
|||
yes, I'm using ksh, the default shell in openbsd.
Actually I've read quite a few articles on the web on the subject, but still cannot appreciate the difference between shells. Probably because I don't really do any serious programming. Anyway, it does not work even from sh. With this command it deletes only the first page: Code:
for page in `jot 3 1` ; do djvm -d file.djvu $page ; done |
|
|||
with the echo command I get the same as you, but it does not work on the real file, could it be a problem with the djvm command?
Well well, I'd better get some sleep now |
|
||||
The command
% jot 10 1 Should output Code:
1 2 3 4 5 6 7 8 9 10 Testing the djvm command is also simple: % djvm -d file.djvu n
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. |
|
|||
For command substitution I prefer to use the the "$( .... )" construct instead of the archaic backquotes ` ..... ` format.
Code:
for page in $(jot 3 1) ; do echo $page ; done 1 2 3
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
well, I've tried it again, it echoes page 1 2 3 but then when cheching the file it only deleted one page.
|
|
|||
the page number means the actual page number according to the djvu order (like in a pdf file, the thumbnails are ordered 1 2 3 etc, but on the actual picture the number might be different). If I run djvm with pagenumber 3, it will delete the third image, and of course, after deleting it, the fourth image will have become the third etc.
Anyway, I've solved it running n times the command on page one. It was a way to learn some more scripting. Very bad that this djvm command does not support page ranges... |
|
||||
Quote:
Code:
#!/bin/sh count=1 until [ $count -gt 10 ]; do djvm -d file.djvu 1 count=`$count + 1` done
__________________
The best way to learn UNIX is to play with it, and the harder you play, the more you learn. If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD |
|
||||
Quote:
Code:
for i in $(jot 10 1) ; do djvm -d file.djvu 1 ; done |
|
|||
thanks you all
I did already use DutchDaemon's solution. If you remember you gave it to me some time ago to run it on .tex files. If I understan properly s0xxx 's solution does exactly the same thing. |
|
||||
Right. Sure. There's always more than one way
|
|
|||
Quote:
Code:
Ghost*Rider@CrackBox-X64:~$ jot 10 1 1 2 3 4 5 6 7 8 9 10 Ghost*Rider@CrackBox-X64:~$ |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
sparc ultra 5 ok== files and args ??? | philo_neo71 | FreeBSD Installation and Upgrading | 2 | 21st September 2009 03:43 AM |
repeat same command n times | gosha | Programming | 8 | 12th March 2009 11:25 PM |
Passing args to port / make while installing apache | robot | FreeBSD Ports and Packages | 2 | 27th August 2008 01:55 PM |
Thanked X times in X posts | johnlvs2run | Feedback and Suggestions | 6 | 18th May 2008 01:21 PM |
Daemonforums very slow, times out a lot | Weaseal | Feedback and Suggestions | 15 | 16th May 2008 12:44 AM |