shell - 执行 shell 脚本时找不到 fc
问题描述
我有以下 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
. 知道为什么我会收到此错误吗?
解决方案
仅供参考: fc 似乎只是 zsh 的内置命令。我猜你没有在文件顶部添加#!/bin/zsh,所以shell默认会在bash环境中执行。因此终端给你错误 fc: not found。
解决
在第一行添加#!/bin/zsh
推荐阅读
- java - 在 SAP Cloud SDK 中使用 Java 为 SFSF 生成 VDM:生成的 URI 错误
- junit - Mockito 核心匹配器-GreaterThan
- apache-spark - 我收到此错误“对象 ml 不是包 org.apache.spark 的成员”
- php - 如何安装 mcrypt PHP 模块
- python - 从 html 表单中获取图像的 Python 问题
- python - 需要预先加载模块时在 VS 代码中运行 pytest
- php - 批量插入 Eloquent Collection - Lumen/Laravel
- amazon-web-services - Terraform:导入现有的互联网网关并附加到 vpc
- jquery - 从大型 json 文件中访问 json 对象的数字键值
- azure - 使用 Azure 服务的具有身份验证、授权和持久层的 Xamarin 应用程序