【发布时间】:2015-12-30 07:50:03
【问题描述】:
我尝试使用 C 编程,但出现错误“sh: 1:
历史:未找到”。
我的c编程代码
int main ()
{
char command[50];
strcpy( command,"history | tail -20" );
system(command);
return(0);
}
【问题讨论】:
我尝试使用 C 编程,但出现错误“sh: 1:
历史:未找到”。
我的c编程代码
int main ()
{
char command[50];
strcpy( command,"history | tail -20" );
system(command);
return(0);
}
【问题讨论】:
在bash 中,您可以访问环境变量$HISTFILE。使用参数 -ci 调用 shell。 -c 运行命令,-i 为 shell 提供一个包含所有可用环境变量的交互式环境。
bash -ic 'tail -20 $HISTFILE'
【讨论】: