Someone posted this in a light hearted slack channel at work.
Note being content with that level of silliness, I thought I’d try to take it to 11.
F=ham && echo '{"JSON" : "stat -s '${F}'"}' \ | jq -r .JSON \ | bash -x \ | perl -pe 's/(\w+)=(\w+)/"$1":$2,/g;' \ | sed 's/.$//' \ | echo '{' $(cat -) '}' \ | jq .
stat -s ham
{
"st_dev": 16777220,
"st_ino": 8637104130,
"st_mode": 100644,
"st_nlink": 1,
"st_uid": 502797,
"st_gid": 10002,
"st_rdev": 0,
"st_size": 0,
"st_atime": 1590682534,
"st_mtime": 1590682534,
"st_ctime": 1590682534,
"st_birthtime": 1590676746,
"st_blksize": 4096,
"st_blocks": 0,
"st_flags": 0
}
Can you use fewer lines to get from the echo statement to the output?