我尝试从C编程,但给出错误"sh: 1:历史记录:not found"。
我的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'