当前位置:首页 » 操作系统 » lua安装linux

lua安装linux

发布时间: 2024-05-13 21:45:25

linux平台:使用lua语言遍历某一文件夹下所有文件

你可以参考如下实例代码:

functiongetFile(file_name)
localf=assert(io.open(file_name,'r'))
localstring=f:read("*all")
f:close()
returnstring
endfunctionwriteFile(file_name,string)
localf=assert(io.open(file_name,'w'))
f:write(string)
f:close()
end--从命令行获取参数,如果有参数则遍历指定目录,没有参数遍历当前目录ifarg[1]~=nilthen
cmd="ls"..arg[1]
else
cmd="ls"endprint("cmd",cmd)
--io.popen返回的是一个FILE,跟c里面的popen一样locals=io.popen(cmd)
localfileLists=s:read("*all")
print(fileLists)
whiletruedo--从文件列表里一行一行的获取文件名_,end_pos,line=string.find(fileLists,"([^ ]+.txt)",start_pos)
ifnotend_posthenbreakend--print("wld",line)localstr=getFile(line)
--把每一行的末尾1,替换为0,localnew=string.gsub(str,"1, ","0, ");
--替换后的字符串写入到文件。以前的内容会清空writeFile(line,new)
start_pos=end_pos+1end

㈡ Lua 的utf8库及使用方法

a utf-8 support mole for Lua and LuaJIT
源码地址: https://github.com/starwing/luautf8

编译后可用的库: https://github.com/cherishpf/luautf8
https://download.csdn.net/download/cherishpf/11579451
Linux版:lua-utf8.so
Windows版:lua-utf8.dll(若是用在openresty中,openresty版本需使用32位版本,使用64位版本时会报错“lua-utf8.dll 不是有效的 Win32 应用程序”)
将lua-utf8库放在openresty安装目录下,使用时用require引入。

㈢ linux怎么卸载lua5.2

linux 中卸载软件有多种方式:

  1. 如果是图形界面, 可以使用应用商店卸载

  2. 命令行可以使用 apt-get remove 卸载, 在用apt-get autoremove 清除残留

  3. 找到软件安装目录下的卸载脚本卸载,然后将残留文件删除即可

  4. 其他方式可以参考readme文档

热点内容
如何查询水星路由器拨号密码 发布:2025-09-15 00:21:06 浏览:308
存储过程嵌套循环 发布:2025-09-15 00:15:24 浏览:666
什么手游脚本好用 发布:2025-09-14 23:18:08 浏览:646
电脑主板和服务器有什么区别 发布:2025-09-14 23:16:33 浏览:116
android下载代码 发布:2025-09-14 23:09:40 浏览:736
ftp拓展名 发布:2025-09-14 22:41:03 浏览:524
sql时间年月 发布:2025-09-14 22:40:00 浏览:809
web直播源码 发布:2025-09-14 22:39:42 浏览:752
hibernate对象缓存 发布:2025-09-14 22:25:37 浏览:877
crsa加密文件 发布:2025-09-14 22:14:19 浏览:102