【发布时间】:2018-06-16 00:24:58
【问题描述】:
首先,我在这里阅读了这篇文章: Bash alias create file with current timestamp in filename
但是,当我运行它时,我一直得到相同的时间戳。这对我来说毫无意义。
我在 Windows 10 上运行 Git bash(来自 git 2.16.2)。我在 ~/.bash_aliases 中添加了以下行:
alias logfile="adb logcat -v threadtime *:V | tee /c/Users/username/Desktop/adb-logs/'$(date +%Y-%m-%d@%Hh%Mm%Ss)'-FullLogCat.log"
这似乎创建了一个日志文件并按照我的意愿在屏幕上显示 ADB 日志。但是,实际日期似乎在加载终端的同时“卡住”了。例如,我在下午 2:29:09 加载终端,然后等到下午 2:30:00 调用别名,文件被标记为“2018-04-24@14h29m09s-FullLogCat.log”。似乎配置文件将别名加载到内存中时,它执行了日期函数。
有没有办法防止这种情况发生?这只是一个奇怪的 git bash 事情吗?
更新:解决方案
alias logfile='adb logcat -v threadtime *:V | tee /c/Users/ghannan/Desktop/adb-logs/''$(date +%Y-%m-%d@%Hh%Mm%Ss)''-FullLogCat.log
【问题讨论】: