当前位置:首页 » 操作系统 » 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文档

热点内容
app什么情况下找不到服务器 发布:2025-05-12 15:46:25 浏览:714
php跳过if 发布:2025-05-12 15:34:29 浏览:467
不定时算法 发布:2025-05-12 15:30:16 浏览:131
c语言延时1ms程序 发布:2025-05-12 15:01:30 浏览:166
动物园灵长类动物配置什么植物 发布:2025-05-12 14:49:59 浏览:736
wifi密码设置什么好 发布:2025-05-12 14:49:17 浏览:148
三位数乘两位数速算法 发布:2025-05-12 13:05:48 浏览:397
暴风影音缓存在哪里 发布:2025-05-12 12:42:03 浏览:542
access数据库exe 发布:2025-05-12 12:39:04 浏览:630
五开的配置是什么 发布:2025-05-12 12:36:37 浏览:365