I couldn't find it on the man page so here we go. I'm opening multiple documents of same type (.pdf
, .tex
etc.) on a daily basis. According to this, it's possible, however I'm looking for a more neat way/shorter code i.e. insted of evince file.ext file.ext ...
I'd like something like evince file.ext*4
. Thanks in advance!
-
Do you want to open 4 times the same file?– BruniSep 5, 2017 at 6:25
-
I picked four as an arbitrary #. I'm looking for something general (2, 3, 4, ...).– ThomasSep 5, 2017 at 6:26
-
Yes, but shall it be the exact same file?– BruniSep 5, 2017 at 6:29
-
Oh yes the same file.– ThomasSep 5, 2017 at 8:42
-
That would be the last part of my answer, though admittedly it is not much neater.– BruniSep 5, 2017 at 8:51
2 Answers
If you want to open multiple documents of same type, you just have to match the part that is similar in the files you want to open.
E.g. if you want to open all pdf files in a folder, you would run
evince *.pdf
if you want to open all pdf files beginning with 2 you would run
evince 2*.pdf
If, what you meant is opening 4 times the same file, you could run
for i in $(seq 4); do evince file.ext & done
Here you can find some more examples on pattern matching.
-
trying to use that on
masterpdfeditor4
didn't work only opens first pdf file found... Sep 5, 2017 at 7:02 -
@George did you try the pattern matching or the loop? Pattern matching works with okular and should work with all commands that accept more than one file as a command line argument. Unfortunately I am not aware of masterpdfeditor4– BruniSep 5, 2017 at 7:06
-
I wrote a for loop for that but
masterpdfeditor4
doesn't seem to be able to handle file names withspaces
Sep 5, 2017 at 8:24 -
@George That is not masterpdfeditor4's fault. My code does not escape spaces and bash uses space as a file delimiter– BruniSep 5, 2017 at 8:33
-
If you're ok with a shell function in your profile you could do this:
ev() {
[[ -z "$*" ]] && echo "usage: ev file [files] [#rpt]" ||
case ${@:$#} in
*[!0-9]*) evince $*;;
*) evince `yes ${@:1:$#-1} |head -${@:$#}`;;
esac
}
For example, ev foo.tex 2
runs evince foo.tex foo.tex
. If the last argument is not a number, evince is run with the regular arguments.