free
Shell-读/写txt文件
  • 首页 > 技术 > Shell
  • 作者:free
  • 2022年11月16日 15:58 星期三
  • 浏览:2843
  • 字号:
  • 评论:0
  • 写入txt:


    version="V1.0"
    commit="fix:修改了部分内容"
    name=$version"-debug"
    
    echo $commit > ./$name.txt



    判断文件是否存在:


    isExist=`find . -name "b.txt"`
    if [ "$isExist" =  "" ];then
    	echo "不存在"
    else
    	echo "存在"
    fi
     # 在当前目录及其子目录下查找 `test.txt` 文件,不存在则无输出;
     # 若存在,则输出相关信息



    读取txt:


    content=""
    while read line
    do
      content=$content$line
      echo "content = "$content
    done < ./$name.txt



      您阅读这篇文章共花了:  
     本文无需标签!
    二维码加载中...
    本文作者:free      文章标题: Shell-读/写txt文件
    本文地址:https://renchuanchuan.com/?post=32
    版权声明:若无注明,本文皆为“RCC”原创,转载请保留文章出处。