#!/bin/bash
#1 读取文件 并显示
cat state.txt | while read line
do
echo $line
done #2 读取文件 并显示
cat state.txt | while read line; do echo $line; done #3 读取一个文件内容到一个变量中
var=$(cat state.txt)
echo $var
#4 根据变量进行判读
if [ $var==0 ]; then
echo "no run"
elif [ $var==1 ]; then
echo "run"
else
echo "error"
fi

运行python的时候将程序PID写入文件,以方便kill程序。

import os  

def writePid():
pid = str(os.getpid())
f = open('athena.pid', 'w')
f.write(pid)
f.close()

sh 字符串匹配

https://blog.csdn.net/xy913741894/article/details/74355576

linux sh 读取文件内容,if判读语句,变量var打印的更多相关文章

  1. 7 RandomAccessFile读取文件内容保存--简单例子(需要验证)

    import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; /** * 读取动态产生的文件内容 */ publ ...

  2. linux下查看文件内容cat,more,less

    1. 查看文件内容经常使用的命令 cat : 由第一行显示文件内容 tac:  从最后一行開始显示.与cat相反 nl :  文件内容和行号一起输出 more: 一页一页显示 less: 与more类 ...

  3. [转]linux查看日志文件内容命令

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...

  4. linux查看日志文件内容命令tail、cat、tac、head、echo

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...

  5. 【Linux】linux查看日志文件内容命令tail、cat、tac、head、echo

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...

  6. Node.js读取文件内容

    原文链接:http://blog.csdn.net/zk437092645/article/details/9231787 Node.js读取文件内容包括同步和异步两种方式. 1.同步读取,调用的是r ...

  7. linux查看日志文件内容命令tail、cat、tac、head、echo、vi

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...

  8. linux查看日志文件内容命令tail、cat、tac、head、echo详解

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...

  9. Linux上读取文件

    Linux上读取文件的方法: #!/bin/bash # This is a script for test exec CONFIG_FILE=$ #该脚本传一个文件名为参数 FILE_NO= ech ...

随机推荐

  1. spark 分区

    http://stackoverflow.com/questions/39368516/number-of-partitions-of-spark-dataframe

  2. scope_identity() 与 @@identity的区别

    在一条 INSERT.SELECT INTO 或大容量复制语句完成后,@@IDENTITY 中包含语句生成的最后一个标识值.如果语句未影响任何包含标识列的表,则 @@IDENTITY 返回 NULL. ...

  3. [SQL in Azure] High Availability and Disaster Recovery for SQL Server in Azure Virtual Machines

    http://msdn.microsoft.com/en-us/library/azure/jj870962.aspx Microsoft Azure virtual machines (VMs) w ...

  4. 每日英语:China Destroys Six Tons of Confiscated Ivory

    BEIJING—Chinese government officials destroyed more than six tons of ivory that had been illegally s ...

  5. Gitlab日常备份和恢复

    按照官方安装文档安装完成之后的/home/git目录结构如下,这里我大致翻译官方的内容,部分加上自己的话,英语功力捉急,请见谅 |-- home | |-- git | |-- .ssh | |-- ...

  6. 兼容ios和Android的复制js代码

    //2种方法本人全部亲测有效 方法1:比较简单 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

  7. dubbo超时重试和异常处理

    dubbo超时重试和异常处理 dubbo超时重试和异常处理 参考: https://www.cnblogs.com/ASPNET2008/p/7292472.html https://www.tuic ...

  8. stopManagedWebLogic.sh强制关闭Managed Server

    Adding force shutdown of managed server in weblogic. ----------------------------------------------- ...

  9. iOS开发中的压缩以及解压

    事实上,在iOS开发中,压缩与解压,我都是采用第三方框架SSZipArchive实现的 gitHub地址:   https://github.com/ZipArchive/ZipArchive 上面有 ...

  10. [转]bigdecimal 保留小数位

    原文地址:https://www.cnblogs.com/liqforstudy/p/5652517.html public class test1_format { public static vo ...