Here is what I came up with:
Code: Select all
function Initialize()
inputFile = SKIN:GetVariable('@')..'LuaDisksInput.txt'
outputFile = SKIN:GetVariable('@')..'LuaDisksOutput.txt'
end
function GetdisksCMD()
local lines = {}
for line in io.lines(inputFile) do
if string.match(line, '^%s*Disk %d* .*$') ~= nil then table.insert(lines, line) end
end
local output = io.open(outputFile, 'w')
output:write(table.concat(lines, '\n'))
output:close()
end
Basically, this iterates over every line in the file, trying to match each line to
^%s*Disk %d* .*$. This regex looks for, on a single line, any amount of whitespace characters, then
Disk (one or more digits), then a space, then literally anything else before the end of the line. If it matches this, then it'll save that line to another table. Once it has iterated over the entire input, it will write the contents of the table to the output file, like this:
Code: Select all
Disk 0 Online 465 GB 0 B *
Disk 1 Online 465 GB 2048 KB *
Disk 2 Online 931 GB 0 B
Is this what you were looking for?