When using the command find, I often need to have a flow control, e.g. if .. then.
A simplified example;
find ~ -maxdepth 1 -type d -exec echo -e "\nnext beg of new dir::" \; -exec ls -lad \{\} \;
The test -type d returns true if current file is of the type directory, thus I see blank lines and the notice that a dir follows.
Yet I want the next -exec to show the output of ls for each file, directory or non-directory.
Using the option -o before the second -exec is not the solution. That inverts the flow control, the files which are not directories are listed. Like if giving -not -type d.
A solution seems to be when writing both options, -not -type d and -o, like this:
find ~ -maxdepth 1 -type d -exec echo -e "\nnext beg of new dir::" \; -not -type d -o -exec ls -lad \{\} \;
Is this the official way to "undo" -type d?
-type f(what is not dir is file) – Romeo Ninov Dec 11 '23 at 18:58