Простой Perl один лайнер:
perl -MFile::Find=find -le'find(sub{/\.c\z/ and -f and $c{$File::Find::dir}=++$c}, @ARGV); print 0 + keys %c, " $c"' dir1 dir2
Или проще с командой find:
find dir1 dir2 -type f -name '*.c' -printf '%h\0' | perl -l -0ne'$c{$_}=1}{print 0 + keys %c, " $."'
Если вам нравится играть в гольф и иметь последние (например, менее десятилетия) Perl:
perl -MFile::Find=find -E'find(sub{/\.c$/&&-f&&($c{$File::Find::dir}=++$c)},".");say 0+keys%c," $c"'
find -type f -name '*.c' -printf '%h\0'|perl -0nE'$c{$_}=1}{say 0+keys%c," $."'
Как насчет этого для начала:
complatex ()
{
if [[ -n $1 ]]; then
pdflatex -output-directory $(dirname "$1") "$1" &&
xdg-open "${1%%.tex}.pdf"
else
for i in *.tex; do
if [[ ! -f ${i%%.tex}.pdf ]]; then
pdflatex "$i" &&
xdg-open "${i%%.tex}.pdf"
fi
done
fi
}
Oneline version:
complatex(){ if [[ $1 ]]; then pdflatex -output-directory $(dirname "$1") "$1" && xdg-open "${1%%.tex}.pdf"; else for i in *.tex; do if [[ ! -f ${i%%.tex}.pdf ]]; then pdflatex "$i" && xdg-open "${i%%.tex}.pdf"; fi; done; fi ;}
Эта функция проверяет аргумент, если он есть, он просто запускает pdflatex сохраняя выходные файлы в каталоге аргумента (вместо текущего) и открывая вывод .pdf в программе просмотра PDF по умолчанию. Если вы вызываете его без аргумента, он проходит через каждый .tex файл в текущем каталоге, проверяет, есть ли .pdf с тем же именем и только если он не делает то же самое, что и выше.
To сделайте команду complatex доступной в вашей системе, просто скопируйте одну из двух версий сверху или в ваш ~/.bash_aliases (создайте ее, если необходимо) или ваш файл ~/.bashrc, и откройте новый терминал или источник измененного файла в существующий, например, source ~/.bash_aliases.
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
└── test.tex
$ complatex test.tex &>/dev/null # opens test.pdf in PDF viewer
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ cd other\ dir/
$ complatex ../test.tex &>/dev/null # opens test.pdf in PDF viewer
$ ls # other dir stays empty
$ cd ..
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ complatex &>/dev/null # opens test.pdf in PDF viewer, doesn't process dummy.tex as there's a dummy.pdf already
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
Как насчет этого для начала:
complatex ()
{
if [[ -n $1 ]]; then
pdflatex -output-directory $(dirname "$1") "$1" &&
xdg-open "${1%%.tex}.pdf"
else
for i in *.tex; do
if [[ ! -f ${i%%.tex}.pdf ]]; then
pdflatex "$i" &&
xdg-open "${i%%.tex}.pdf"
fi
done
fi
}
Oneline version:
complatex(){ if [[ $1 ]]; then pdflatex -output-directory $(dirname "$1") "$1" && xdg-open "${1%%.tex}.pdf"; else for i in *.tex; do if [[ ! -f ${i%%.tex}.pdf ]]; then pdflatex "$i" && xdg-open "${i%%.tex}.pdf"; fi; done; fi ;}
Эта функция проверяет аргумент, если он есть, он просто запускает pdflatex сохраняя выходные файлы в каталоге аргумента (вместо текущего) и открывая вывод .pdf в программе просмотра PDF по умолчанию. Если вы вызываете его без аргумента, он проходит через каждый .tex файл в текущем каталоге, проверяет, есть ли .pdf с тем же именем и только если он не делает то же самое, что и выше.
To сделайте команду complatex доступной в вашей системе, просто скопируйте одну из двух версий сверху или в ваш ~/.bash_aliases (создайте ее, если необходимо) или ваш файл ~/.bashrc, и откройте новый терминал или источник измененного файла в существующий, например, source ~/.bash_aliases.
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
└── test.tex
$ complatex test.tex &>/dev/null # opens test.pdf in PDF viewer
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ cd other\ dir/
$ complatex ../test.tex &>/dev/null # opens test.pdf in PDF viewer
$ ls # other dir stays empty
$ cd ..
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ complatex &>/dev/null # opens test.pdf in PDF viewer, doesn't process dummy.tex as there's a dummy.pdf already
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
Как насчет этого для начала:
complatex ()
{
if [[ -n $1 ]]; then
pdflatex -output-directory $(dirname "$1") "$1" &&
xdg-open "${1%%.tex}.pdf"
else
for i in *.tex; do
if [[ ! -f ${i%%.tex}.pdf ]]; then
pdflatex "$i" &&
xdg-open "${i%%.tex}.pdf"
fi
done
fi
}
Oneline version:
complatex(){ if [[ $1 ]]; then pdflatex -output-directory $(dirname "$1") "$1" && xdg-open "${1%%.tex}.pdf"; else for i in *.tex; do if [[ ! -f ${i%%.tex}.pdf ]]; then pdflatex "$i" && xdg-open "${i%%.tex}.pdf"; fi; done; fi ;}
Эта функция проверяет аргумент, если он есть, он просто запускает pdflatex сохраняя выходные файлы в каталоге аргумента (вместо текущего) и открывая вывод .pdf в программе просмотра PDF по умолчанию. Если вы вызываете его без аргумента, он проходит через каждый .tex файл в текущем каталоге, проверяет, есть ли .pdf с тем же именем и только если он не делает то же самое, что и выше.
To сделайте команду complatex доступной в вашей системе, просто скопируйте одну из двух версий сверху или в ваш ~/.bash_aliases (создайте ее, если необходимо) или ваш файл ~/.bashrc, и откройте новый терминал или источник измененного файла в существующий, например, source ~/.bash_aliases.
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
└── test.tex
$ complatex test.tex &>/dev/null # opens test.pdf in PDF viewer
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ cd other\ dir/
$ complatex ../test.tex &>/dev/null # opens test.pdf in PDF viewer
$ ls # other dir stays empty
$ cd ..
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ complatex &>/dev/null # opens test.pdf in PDF viewer, doesn't process dummy.tex as there's a dummy.pdf already
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
Как насчет этого для начала:
complatex ()
{
if [[ -n $1 ]]; then
pdflatex -output-directory $(dirname "$1") "$1" &&
xdg-open "${1%%.tex}.pdf"
else
for i in *.tex; do
if [[ ! -f ${i%%.tex}.pdf ]]; then
pdflatex "$i" &&
xdg-open "${i%%.tex}.pdf"
fi
done
fi
}
Oneline version:
complatex(){ if [[ $1 ]]; then pdflatex -output-directory $(dirname "$1") "$1" && xdg-open "${1%%.tex}.pdf"; else for i in *.tex; do if [[ ! -f ${i%%.tex}.pdf ]]; then pdflatex "$i" && xdg-open "${i%%.tex}.pdf"; fi; done; fi ;}
Эта функция проверяет аргумент, если он есть, он просто запускает pdflatex сохраняя выходные файлы в каталоге аргумента (вместо текущего) и открывая вывод .pdf в программе просмотра PDF по умолчанию. Если вы вызываете его без аргумента, он проходит через каждый .tex файл в текущем каталоге, проверяет, есть ли .pdf с тем же именем и только если он не делает то же самое, что и выше.
To сделайте команду complatex доступной в вашей системе, просто скопируйте одну из двух версий сверху или в ваш ~/.bash_aliases (создайте ее, если необходимо) или ваш файл ~/.bashrc, и откройте новый терминал или источник измененного файла в существующий, например, source ~/.bash_aliases.
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
└── test.tex
$ complatex test.tex &>/dev/null # opens test.pdf in PDF viewer
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ cd other\ dir/
$ complatex ../test.tex &>/dev/null # opens test.pdf in PDF viewer
$ ls # other dir stays empty
$ cd ..
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex
$ rm -f test.!(tex) # removes the output files that were just created
$ complatex &>/dev/null # opens test.pdf in PDF viewer, doesn't process dummy.tex as there's a dummy.pdf already
$ tree -A --noreport
.
├── dummy.pdf
├── dummy.tex
├── other\ dir
├── test.aux
├── test.log
├── test.pdf
└── test.tex