Files » obtaining a list of files and their paths

This commit is contained in:
Kenneth John Odle 2026-08-19 08:50:35 -04:00
parent 0b91070e4a
commit 4d8b867007
2 changed files with 11 additions and 2 deletions

View File

@ -24,4 +24,12 @@ To obtain this list with a relative path, use:
find . find .
\end{Verbatim} \end{Verbatim}
To find only certain types of files (in this case jpgs) and redirect this information to a file, use something like this:
\begin{Verbatim}[]
find . \( name "*.jpg" -o name "*.jpeg" \) > jpglist.txt
\end{Verbatim}
Because this is bash, the parentheses are not a capture group (as in regex), but operators used to force precedence and need to be escaped, because parentheses are special to the shell. (Normally we would use quotation marks, but because we need to use quotation marks with the \texttt{name} test, we are using backslashes). Likewise, the \texttt{-o} is a Boolean ``or'', meaning that the second expression will not be evaluated if the first one is true. For more information, use \texttt{man find}.
\ktcbox{Sometimes you need a list of files with their filepaths, and these tools will do that. Unfortunately, Linux does not have a way to put the file first, so the way to do this is to redirect \texttt{stdout} to a \texttt{.csv} file and manipulate the output in a spreadsheet.} \ktcbox{Sometimes you need a list of files with their filepaths, and these tools will do that. Unfortunately, Linux does not have a way to put the file first, so the way to do this is to redirect \texttt{stdout} to a \texttt{.csv} file and manipulate the output in a spreadsheet.}

View File

@ -9,8 +9,8 @@
%%% Get it started %%% Get it started
\checkandfixthelayout % Required if you have altered settings for the memoir class \checkandfixthelayout % Required if you have altered settings for the memoir class
% Make an index % Make an index
\makeindex[columns=3, title=Packages Mentioned, intoc] \makeindex[title=Commands, intoc, columnseprule]
\makeindex[name=concepts, columns=3, title=Concepts, intoc] \makeindex[name=concepts, title=Concepts, intoc, columnseprule]
\begin{document} \begin{document}
\pagenumbering{roman} \pagenumbering{roman}
@ -45,6 +45,7 @@
\input{chapters/ch01-images} \input{chapters/ch01-images}
\input{chapters/ch02-text} \input{chapters/ch02-text}
\input{chapters/ch03-files} \input{chapters/ch03-files}
\input{chapters/ch04-system}
\printindex \printindex
\printindex[concepts] \printindex[concepts]