I have below script
size=$1
big_files_list=$(find . -name \*.bytes -type f -printf "%b %h/%f\n" |
awk -v size="$size" '
function basename(file) {
sub(".bytes$", ".properties", file)
return file
}
{if ($1 > size) {
print basename($2) }}')
for i in ${big_files_list}; do
echo "\t"
grep -E 'size|repo-name|creationTime|ob-name|sha' $i | tr "\n" ","
done
which prints below output
size=992198
repo-name=testupload
creationTime=1603278566981
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
size=992198
repo-name=testupload
creationTime=1603278566981
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
size=992198
repo-name=testupload
creationTime=1603278566981
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
size=992198
repo-name=testupload
creationTime=1603278566981
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
which grep and prints date from file where creationTime is in unix timestamp I know we can use date -d @1603278566981 to convert it to readable but records are in many numbers,
any way we can convert that before final output. so final output should be like below
size=992198
repo-name=testupload
creationTime=Sun Nov 16 22:29:41 CET 52775
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
size=992198
repo-name=testupload
creationTime=Sun Nov 16 22:29:41 CET 52775
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
size=992198
repo-name=testupload
creationTime=Sun Nov 16 22:29:41 CET 52775
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
size=992198
repo-name=testupload
creationTime=Sun Nov 16 22:29:41 CET 52775
ob-name=cargotracker-master.zip
sha1=ca8bb4e3ddb802a228e945a8fe32c308b2e3d555
Please help,
Samurai
EDIT: here is the above code better formatted for readability:
size=$1
big_files_list=$(
find . -name \*.bytes -type f -printf "%b %h/%f\n" |
awk -v size="$size" '
function basename(file) {
sub(".bytes$", ".properties", file)
return file
}
{
if ($1 > size) {
print basename($2)
}
}
'
)
for i in ${big_files_list}; do
echo "\t"
grep -E 'size|repo-name|creationTime|ob-name|sha' $i | tr "\n" ","
done
How about the following using GNU awk:
awk '/size|repo-name|creationTime|ob-name|sha/ {
print
}
/creationTime/ {
split($0,map,"-");
dat=(map[2]/10000000)-11644473600;
print "creationTime="strftime("%c",dat)
} $(find <fulldirectorypath> -name "*.bytes" -size="+$size" -type f -printf "%h/%f\n" | awk '{ split($0,map,".");print map[1]".properties" }')
First, let find do the size processing with the -size parameter and pipe the output to awk to change the extention from bytes to properties. Then process these file with awk. For all entries apart from creationTime, simply print the lines. For creation time, process the unix timestamp and print in locale form.
This hasn't been tested so there maybe errors.
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.