您的位置 首页 > 数码极客

「deletefile」deletefile 错误码5?

最近,看到redis自己的测试代码,于是简单了解一下,总结一下file命令的简单实用,不废话,上代码

#!/usr/bin/tclsh set path $argv0 # atime: 以UNIX时间戳形式,返回/设置文件的访问时间 puts "atime: [file atime $path]" # 返回/设置文件属性信息 puts "attributes: [file attributes $path]" # 返回单个文件属性信息 puts "attibutes, permission: [file attributes $path -permission]" # 设置单个文件属性 set ret [file attributes $path -permission 00777] puts "attibutes, set permission: [file attributes $path -permission]" # 查看文件信息 unset ret file stat $path ret puts "file stat: " parray ret # 删除文件 file delete a.txt puts "del file, name: a.txt" # 复制文件 file copy $path a.txt puts "copy file, src: $path, dst: a.txt" # 复制文件,但是文件已存在则覆盖 file copy -force $path a.txt puts "force copy file, src: $path, dst: a.txt" # 连续--用于预设参数部分结束,后续全是文件名,用于文件名以-开头的字符串 file copy -force $path -a.txt file copy -force -- -a.txt xxx.txt # 删除文件/目录 file delete -force -- a.txt -a.txt xxx.txt puts "delete file" # 级联创建目录 file mkdir X/XX/XXX puts "mkdir X/XX/XXX" # 返回原生路径,不识别文件是否存存在 unset ret set ret [file nativename ~/ok] puts "native, source: ~/ok, native: $ret" # 返回文件绝对路径,唯一标准化路径 unset ret set ret [file normalize $path] puts "normalize, source: $argv0, native: $ret" # 返回目录名称 unset ret set ret [file dirname [file normalize $path]] puts "dirname, path: [file normalize $path], dir: $ret" # 验证文件是否可执行 puts "path exec? path: $path, exec: [file executable $path]" # 验证文件是否存在 puts "path exists? path: $path, exist: [file exists $path]" # 返回文件扩展名 puts "path extension, path: $path, extension: [file extension $path]" # 检查是否是目录 set dir [file dirname [file normalize $path]] puts "is dir? path: $dir, isdir: [file isdirectory $dir]" # 创建链接 set linkfile file delete -force $linkfile file link -symbolic $linkfile $path puts "create link, src: $path, dst: $linkfile, return link source file: [file readlink $linkfile]" # 符号链接信息,链接本身,非链接指向的文件 unset ret set linkfile file lstat $linkfile ret puts "symbol: " parray ret # 多个字符串串成路径 puts "join str: [file join xxx yyy zzz ddd wu]" # 判定是否是文件 puts "is file: [file isfile $path]" # 返回通道 puts "channels: [file channels], match channels: [file channels "*err"]" # 创建具有临时读写权限的文件, 当前不支持 # unset ret # file tempfile ret "; # puts "temp file: $ret" # 返回修改时间 puts "path: $path, mtime: [file mtime $path]" # 文件大小,单位: B puts "path: $path, size: [file size $path]" # 文件系统 puts "path: $path, file system: [file system $path]" # 是否文件所有者 puts "path: $path, file owned: [file owned $path]" # 相对路径、绝对路径、volumerelative判断 puts "path: $path, abs: [file normalize $path], re: [file pathtype $path], abs: [file pathtype [file normalize $path]]" # 重命名、移动、同名覆盖 # file rename X Y # 返回rootname,仅仅去掉后缀名,意义在哪? puts "rootname, path: $path, rootname: [file rootname [file normalize $path]]" # 拆分路径 puts "split path, path: [file normalize $path], split: [file split [file normalize $path]]" # 路径最后一个部分 puts "path tail, path: [file normalize $path], tail: [file tail [file normalize $path]]" # 路径分隔符 puts "file separator: [file separator]" # 卷 puts "volumes: [file volumes]" # 类型, 还有可能是socket puts "type, [file type $path]" # 可读,可写权限 puts "path: $path, read: [file readable $path], writable: [file writable $path]"


执行结果

fh@Feihu-3 learn % . atime: 1636212405 attributes: -group staff -owner fh -permissions 00777 -readonly 0 -creator {} -type {} -hidden 0 -rsrclength 0 attibutes, permission: 00777 attibutes, set permission: 00777 file stat: ret(atime) = 1636212405 ret(blksize) = 4096 ret(blocks) = 8 ret(ctime) = 1636212604 ret(dev) = 16777222 ret(gid) = 20 ret(ino) = 22849742 ret(mode) = 33279 ret(mtime) = 1636212403 ret(nlink) = 1 ret(size) = 3815 ret(type) = file ret(uid) = 501 del file, name: a.txt copy file, src: ., dst: a.txt force copy file, src: ., dst: a.txt delete file mkdir X/XX/XXX native, source: ~/ok, native: /Users/fh/ok normalize, source: ., native: /Users/fh/fh_data/workspace/tcl/learn dirname, path: /Users/fh/fh_data/workspace/tcl/learn, dir: /Users/fh/fh_data/workspace/tcl/learn path exec? path: ., exec: 1 path exists? path: ., exist: 1 path extension, path: ., extension: .tcl is dir? path: /Users/fh/fh_data/workspace/tcl/learn, isdir: 1 create link, src: ., dst: , return link source file: . symbol: ret(atime) = 1636212604 ret(blksize) = 4096 ret(blocks) = 0 ret(ctime) = 1636212604 ret(dev) = 16777222 ret(gid) = 20 ret(ino) = 22858687 ret(mode) = 41453 ret(mtime) = 1636212604 ret(nlink) = 1 ret(size) = 9 ret(type) = link ret(uid) = 501 join str: xxx/yyy/zzz/ddd/wu is file: 1 channels: stdin stdout stderr, match channels: stderr path: ., mtime: 1636212403 path: ., size: 3815 path: ., file system: native path: ., file owned: 1 path: ., abs: /Users/fh/fh_data/workspace/tcl/learn, re: relative, abs: absolute rootname, path: ., rootname: /Users/fh/fh_data/workspace/tcl/learn/run split path, path: /Users/fh/fh_data/workspace/tcl/learn, split: / Users fh fh_data workspace tcl learn run.tcl path tail, path: /Users/fh/fh_data/workspace/tcl/learn, tail: run.tcl file separator: / volumes: / type, file path: ., read: 1, writable: 1 fh@Feihu-3 learn %


文档参考:

责任编辑: 鲁达

1.内容基于多重复合算法人工智能语言模型创作,旨在以深度学习研究为目的传播信息知识,内容观点与本网站无关,反馈举报请
2.仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证;
3.本站属于非营利性站点无毒无广告,请读者放心使用!

“deletefile,deletefile,错误码5,deletefile,错误码5拒绝访问,deletefile,错误码5怎样解决”边界阅读