1

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!

5
  • Do you want to open 4 times the same file?
    – Bruni
    Sep 5, 2017 at 6:25
  • I picked four as an arbitrary #. I'm looking for something general (2, 3, 4, ...).
    – Thomas
    Sep 5, 2017 at 6:26
  • Yes, but shall it be the exact same file?
    – Bruni
    Sep 5, 2017 at 6:29
  • Oh yes the same file.
    – Thomas
    Sep 5, 2017 at 8:42
  • That would be the last part of my answer, though admittedly it is not much neater.
    – Bruni
    Sep 5, 2017 at 8:51

2 Answers 2

2

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.

6
  • 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
    – Bruni
    Sep 5, 2017 at 7:06
  • I wrote a for loop for that but masterpdfeditor4 doesn't seem to be able to handle file names with spaces 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
    – Bruni
    Sep 5, 2017 at 8:33
  • @George just put the filename in double quotes "file.ext"
    – Bruni
    Sep 5, 2017 at 8:53
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .