$ cat somefile.css | awk '{gsub(/{|}|;/,"&\n"); print}' >> uncompressed.css
后來個人用ruby寫了個轉化的代碼:
輸出到控制臺:
path = '/home/feng/compress.css'
string = File.read(path)
puts string.gsub!(/;/,";\n").gsub!(/\}/,"\n}\n").gsub!(/\{/,"\n{\n")
輸出到文件:
path = '/home/feng/compress.css'
file = File.new(path, "r")
path1 = '/home/feng/uncompress.css'
File.open(path1, "wb") do |f|
f.write(file.readline().gsub!(/;/,";\n").gsub!(/\}/,"\n}\n").gsub!(/\{/,"\n{\n"))
end
ref:
http://www.commandlinefu.com/commands/view/2339/uncompress-a-css-file
write by feng |