In a directory, I have a bunch of files like file1.tex, file1.pdf, file2.tex, file2.pdf etc along with other files. I want, preferably a one liner in bash (to include in a make file as dependency), to
- list all tex files if their pdf versions are also available.
- list all pdf files if their tex versions are also available.
EDIT
I had tried
find . \( -name '*.pdf' -name '*.tex' \)
but it did not work. I guess the above approach is useful if I want to find files with pdf or tex extensions by using the -o option between two name switches. thanks
suresh
The Solution
This isn't very readable--it would be much better to make this a script or shell function with some decent line wrapping--but you can force the loop to be a one-liner if you really want to.
Validating the Solution
You can quickly test that the solution works properly with with some sample data.
Note that in both cases, files without complements in the other format are silently ignored.