I am trying to loop through all the sub-directories in a directory and to copy the pathname of all files containing the word "event" into a new listfile. But, for some reason my code only looks at the last sub-directory...any ideas?
for dir in */
do
echo "$dir"
ls -l $dir* | grep events > FullSkim.list
done
You should change >
to >>
.
>
(Redirecting Output): If the file does not exist it is created; if it does exist it is truncated to zero size. >>
(Appending Redirected Output): If the file does not exist it is created; if it does exist it is opened for appending. 你可以改用
find . | grep "events" > file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.