I want to create json holding file name, size and version of files inside a directory. Here version number is a string written inside every file (each file is a lua file containing function like
function M.version()
return "1.0"
end
will tel the version number) I need a bash script that will create json consisting of file name, size and it's corresponding version(taken from inside the file)
eg: I've some lua files, at "/home/anudeep/source" are afile.lua bfile.lua,cfile.lua,dfile.lua,efile.lua,ffile.lua,gfile.lua and inside every lua file there's version function like
function M.version() return "1.0" end
or
function gfile.version() return "1.0" end
my json file shuld be file_info.json containing
{"avaible_files":
[
["afile.lua",2056,"1.0"],
["bfile.lua",948,"2.0"],
["cfile.lua",1054,"1.0.1"],
["dfile.lua",3085,"3.0"],
["efile.lua",9685,"1.0.0"],
["efile.lua",6985,"1.0.2"],
["ffile.lua",9996,"3.1.0"],
["gfile.lua",785,"2.0.0"]
]
}
I don't know much about shell/bash scripting and satrted learning. In that process, tried this command to get file name and version
grep -rs -A1 version .| awk '/return/ {print $ response is ./afile.lua-"1.0"
getting this respone
./bfile.lua-"2.0" ./cfile.lua-"1.0.0.1" ./dfile.lua-"3.0" ./efile.lua-"1.0.0" ./ffile.lua-"1.0.2" ./gfile.lua-"2.0.0"
But can't able to write script to create json. Small help also appriciated thanks in advance