作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最近我决定从 zsh 转移到 bash shell。有没有办法快速将我的 .zsh_history
文件转换为 .bash_history
文件?
.zsh_history
片段
: 1446994188:0;cat .bash_profile
: 1446994197:0;echo $shell
: 1446995957:0;vi ~/.zshrc
: 1437893246:0;curl -fLo ~/.vim/autoload/plug.vim --create-dirs \\
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
.bash_history
片段
#1446994188
cat .bash_profile
#1446994197
echo $shell
#1446995957
vi ~/.zshrc
#1437893246
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
请注意,命令可以跨越多行。
最佳答案
很奇怪,我的 .bash_history 中没有那些注释行,无论如何,我会使用这样的东西
sed 's/^: \([0-9]*\):\w;\(.*\)$/#\1\n\2/' <.zsh_history >.bash_history
我远不是正则表达式方面的专家,所以这可能做得更好,但我会解释它的作用。
sed 's/^ -- start of the line
: -- tell the regexp there's a ":"
\([0-9]*\) -- identify a series of numbers and store that in 1
:\w; -- another ":" followed by a word and by ";"
\(.*\)$ -- store whatever you find until the end of the line in 2
/#\1\n\2/' -- print what you have in 1 on a line and what you have in 2 on the next
关于bash - 将 .zsh_history 文件转换为 .bash_history 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33648032/
最近我决定从 zsh 转移到 bash shell。有没有办法快速将我的 .zsh_history 文件转换为 .bash_history 文件? .zsh_history 片段 : 14469941
我是一名优秀的程序员,十分优秀!