I have the following command:
find ~ -maxdepth 3 -type f -name description -exec stat -c "%n --RDD-- %z" {} \; -exec head -1 {} \;
This finds all the description files 3 folders deep ands outputs something like:
/home/user/public_html/.git/description --RDD-- 2014-12-17 17:02:09.347983909 +0000
Some description
/home/user/public_sub/.git/description --RDD-- 2014-12-17 17:02:09.347983909 +0000
Another description
I would like to concatenate the two execs and get something like:
/home/user/public_html/.git/description --RDD-- 2014-12-17 17:02:09.347983909 +0000 --RDD-- Some description
/home/user/public_sub/.git/description --RDD-- 2014-12-17 17:02:09.347983909 +0000 --RDD-- Another description
I have been trying to get this done for the past day but cannot figure out a how to do it past this point.
You can use --printf
in stat
to avoid printing newline like this:
find ~ -maxdepth 3 -type f -name description \
-exec stat --printf="%n --RDD-- %z --ROD-- " {} \; -exec head -1 {} \;
OR else you can use bash -c
and a command line in your command:
find ~ -maxdepth 3 -type f -name description -exec bash -c \
'f="$1"; stat -c "%n --RDD-- %z --ROD-- $(head -1 "$f")" "$f"' - {} \;
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.