Having identified a directory, it is desired to print the first 4 lines of every file within that directory.
The chosen directory contains many files and a few sub-directories.
find works recursively, and that's desirable.
This code ...
Code:
DoI='/home/daniel/Desktop/LQfiles' # DoI=Directory of Interest
find $DoI \
|xargs head -4 \
>$Work2
... produces the desired result but also flashes error messages to the screen, such as ...
Code:
head: error reading `/home/daniel/Desktop/LQfiles': Is a directory
head: error reading `/home/daniel/Desktop/LQfiles/LQ8': Is a directory
head: error reading `/home/daniel/Desktop/LQfiles/LQ6': Is a directory
head: error reading `/home/daniel/Desktop/LQfiles/LQ7': Is a directory
How may these undesirable messages be eliminated?
Is there an option for
find which should be used?
(I looked but did not find one.)
Is there a way to redirect the error messages to a different file?
(I tried to do that but botched it.)
Please advise.
Daniel B. Martin