(1)当前时间命名临时文件:

按照一定的格式获取当前时间:
date +%y-%m-%d_%H:%M:%S

#generate the file name
tmpfile=`date +%y-%m-%d_%H:%M:%S` #create a empty file
>$tmpfile #do what you want to do using the temp file
#...
# #delete temp file
rm -f $tmpfile

(2)当前进程ID命名临时文件:

获取当前进程ID:

$$

#generate the file name
tmpfile=$$ #create a empty file
>$tmpfile #do what you want to do using the temp file
#...
# #delete temp file
rm -f $tmpfile

(3)隐藏的临时文件

#generate the file name
tmpfile="temp" #Temp file middile name
prefix=. #In Linux env, hide the file use .
suffix=_$$ #Using process ID as the suffix of temp file name
tmpfile=${prefix}${tmpfile}${suffix} #create a empty file
>$tmpfile #do what you want to do using the temp file
#...
# #delete temp file
rm -f $tmpfile

shell基础——创建临时文件的更多相关文章

  1. Linux实战教学笔记17:精简shell基础

    第十七节 精简shell基础 标签(空格分隔): Linux实战教学笔记 1,前言 1.1 为什么学习shell编程 Shell脚本语言是实现Linux/UNIX系统管理及自动化运维所必备的重要工具, ...

  2. Linux Shell基础(下)

    Linux Shell基础(下) 目录 一.shell特殊符号cut命令 二.cut.sort.wc.uniq命令 三.tee.tr.split命令 四.简易审计系统 五.fork, exec, so ...

  3. Linux shell基础知识(上)

    Linux shell基础知识(上) 目录 一.shell介绍 二.命令历史 三.命令补全和别名 四.通配符 五.输入输出重定向 六.管道符和作业控制 七.shell变量 八.环境变量配置文件 九.b ...

  4. Shell基础入门

    目录 Shell基础入门 1.什么是Shell? 2.Shell脚本的结构 3.Shell的变量 3.1.自定义环境变量 3.2.普通变量 3.3.位置参数变量 3.4.状态变量 4.条件测试和比较 ...

  5. linux shell 基础 使用日志与心得

    linux shell 基础 使用日志与心得 1.#!/bin/bash 第一行就出现#!/bin/bash是指此脚本使用/bin/bash来解释执行.其中,#!是一个特殊的表示符,其后,跟着解释此脚 ...

  6. Linux Shell 基础知识(一)

    1. 本文知识结构 2. shell 基础知识 2.1 shell 简单介绍 ​ GNU bash shell 能提供对 Linux 系统的交互式访问,一般来说,使用快捷键 Ctrl + Alt + ...

  7. shell基础、变量、相关脚本

    目录 一.shell基础 书写规范 引号 配置文件 read交互 脚本调式 小节总结 二.变量 变量类型 位置变量 状态变量 替换和删除 变量补充 变量运算 小节总结 三.相关脚本面试题 统计hist ...

  8. Linux正则表达式、shell基础、文件查找及打包压缩

    Linux正则表达式.shell基础.文件查找及打包压缩 一.正则表达式 Linux正则表达式分为2类: 1.基本正则表达式(BRE) 2.扩展正则表达式(ERE) 两者的区别: 1.使用扩展正则表达 ...

  9. -bash: 无法为立即文档创建临时文件: 设备上没有空间---记一次报错

    故障发生原因 测试环境,之前用该机器做过docker-compose,后来有需要用到该机器上的docker环境,需要将旧的docker容器全部删除,由于之前启动是使用docker-compose启动的 ...

随机推荐

  1. HDU 4970 Killing Monsters

    开始以为是线段树,算了一下复杂度也觉得能过...但是这题貌似卡了线段树... 具体做法: 对每一个塔,记录attack[l]+=d,attack[r+1]-=d;这样对于每个block,受到的伤害就是 ...

  2. mysql trigger 权限的说明

    普通用户在创建trigger时会遇到的问题: 1.如果开启了二进制日志,但是用户没有supper 权限:那么他在创建trigger 时会提示设置log_bin_trust_function_creat ...

  3. mysql不能链接远程,报(Host '***.***.***.***' is not allowed to connect to this MySQL server)

    Host '***.***.***.***' is not allowed to connect to this MySQL server 其中***...是本机公网ip; 解决办法: 首先看报错窗口 ...

  4. Bitmap 与ImageSource之间的转换

    public class ImageConverter { [DllImport("gdi32.dll", SetLastError = true)] private static ...

  5. SD card技术了解并WINCE下SDHC驱动开发(updated)

    Suumary: 简单介绍了一下SD卡的历史和发展,同时结合MX31 ADS上的WINCE 下SDHC驱动更深入的了解该硬件的一些行为特点. 了解SD card SD是Secure Digital C ...

  6. HttpWebResponse类

    HttpWebResponse类的作用用于在客户端获取返回的响应的信息,还记得HttpResponse类吗?你是否在写B/S程序的时候,经常用到Response.Write()呢? HttpRespo ...

  7. SQL Server 2008空间数据应用系列十一:提取MapInfo地图数据中的空间数据解决方案

    原文:SQL Server 2008空间数据应用系列十一:提取MapInfo地图数据中的空间数据解决方案 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Serv ...

  8. 一 VC2008环境中ICE的配置

    VC2008环境中ICE的配置 ICE 3.4.0的下载页面 http://www.zeroc.com/download_3_4_0.html 环境变量配置  1.Ice-3.4.0安装到c:\Ice ...

  9. Binary Tree Level Order Traversal II 解答

    Question Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, ...

  10. SVN强制填写日志

    在F:\Repositories\版本库名\hooks下新建pre-commit.bat 内容如下: @echo off setlocal set SVN_BINDIR="C:\Progra ...