1 Star 0 Fork 2

Lq/jd_shell

forked from 飞鹏/jd_shell 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
csv.sh 725 Bytes
一键复制 编辑 原始数据 按行查看 历史
anonymous 提交于 2021-02-05 23:45 . csv.sh
#!/usr/bin/env bash
## 判断环境
ShellDir=${JD_DIR:-$(cd $(dirname $0); pwd)}
LogDir=${ShellDir}/log
Income=${LogDir}/bean_income.csv
Outlay=${LogDir}/bean_outlay.csv
## 执行
cd ${LogDir}/jd_bean_change
for log in $(ls); do
LogDate=$(echo ${log} | cut -c1-10)
BeanDate=$(date "+%Y-%m-%d" -d "1 day ago ${LogDate}")
if [[ -z $(grep "${BeanDate}" ${Income}) ]]; then
echo -n "${BeanDate}," >> ${Income}
grep -E "昨日收入" ${log} | grep -oE "\d+" | perl -0777 -pe "s|\n(\d+)|,\1|g" >> ${Income}
fi
if [[ -z $(grep "${BeanDate}" ${Outlay}) ]]; then
echo -n "${BeanDate}," >> ${Outlay}
grep -E "昨日支出" ${log} | grep -oE "\d+" | perl -0777 -pe "s|\n(\d+)|,\1|g" >> ${Outlay}
fi
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Lq1918/jd_shell.git
git@gitee.com:Lq1918/jd_shell.git
Lq1918
jd_shell
jd_shell
master

搜索帮助