【问题标题】:fc not found when executing a shell script执行 shell 脚本时找不到 fc
【发布时间】:2020-11-12 04:32:37
【问题描述】:

我有以下shell脚本zsh_history_fix.sh:

# Fixes a corrupt .zsh_history file
mv ~/.zsh_history ~/.zsh_history_bad
strings ~/.zsh_history_bad > ~/.zsh_history
fc -R ~/.zsh_history
rm ~/.zsh_history_bad

任何时候我尝试执行./zsh_history_fix.sh,它都会抛出./zsh_history_fix.sh: 4: fc: not found。 知道为什么我会收到此错误吗?

【问题讨论】:

  • 您是否检查了文件中的隐形有趣字符?比如od -bc ./zsh_history_fix.sh

标签: shell ubuntu terminal windows-subsystem-for-linux


【解决方案1】:

仅供参考: fc 似乎只是 zsh 的内置命令。 我猜你没有在文件顶部添加 #!/bin/zsh, 所以shell默认会在bash环境中执行。 因此终端会给你错误 fc: not found。

解决

在第一行添加#!/bin/zsh

【讨论】:

  • fc 是一个 POSIX shell 功能(在 UP = User Portability 选项下),因此它可用于许多 Bournian 血统的 shell。
猜你喜欢
  • 2021-12-29
  • 1970-01-01
  • 1970-01-01
  • 2015-05-02
  • 2022-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-31
相关资源
最近更新 更多