Shell脚本攻略学习笔记十二之mktemp命令
原创
©著作权归作者所有:来自51CTO博客作者说文科技的原创作品,请联系作者获取转载授权,否则将追究法律责任
Shell脚本攻略学习笔记十二之mktemp命令
mktemp — create a temporary file or directory
- Create a temporary file as follows
[root@server4 shells]# mktemp
/tmp/tmp.MeH1jVsPRi
- To create a temporary directory, use the following commands
[root@server4 shells]# mktemp -d
/tmp/tmp.AThosQe1lF
[root@server4 shells]# cd /tmp/tmp.AThosQe1lF/
[root@server4 tmp.AThosQe1lF]# ll
total 0
- To just generate a filename without actually creating a file or directory, use this:
[root@server4 shells]# mktemp -u
/tmp/tmp.3z6y2RQlUp
[root@server4 shells]# cd /tmp/tmp.3z6y2RQlUp
-bash: cd: /tmp/tmp.3z6y2RQlUp: No such file or directory #提示不存在
- To create the temporary filename according to a template, use:
[root@server4 shells]# mktemp test.XXX
test.okb
[root@server4 shells]# mktemp test.xxx
mktemp: too few X's in template ‘test.xxx’
[root@server4 shells]# mktemp test.XX
mktemp: too few X's in template ‘test.XX’
[root@server4 shells]# mktemp test.XXX
test.xv6
[root@server4 shells]# mktemp HH.XXX
HH.8Yy
[root@server4 shells]# mktemp LIUBAI.XXX
LIUBAI.vZ9