我需要从数组中删除制表符空间,并将值与一个数组值与字符串进行比较。
inspec> command("chage -l root").stdout.split("\n").flatten{|x| x.strip || x}
=> ["Last password change\t\t\t\t\t: Feb 27, 2017",
"Password expires\t\t\t\t\t: May 28, 2017",
"Password inactive\t\t\t\t\t: Apr 20, 2067",
"Account expires\t\t\t\t\t\t: Nov 27, 2019",
"Minimum number of days between password change\t\t: 0",
"Maximum number of days between password change\t\t: 90",
"Number of days of warning before password expires\t: 7"]
inspec>
答案 0 :(得分:0)
所以代码将是:
command("chage -l root").stdout.split("\n").flatten{|x| x.strip || x}.map{|x| x.gsub(/\t/, '')}