如何从c程序/shell脚本中激发历史记录命令?
我尝试使用C语言编程,但这会产生错误“sh:1: 历史记录:未找到。“如何从c程序/shell脚本中激发历史记录命令?,shell,terminal,command,Shell,Terminal,Command,我尝试使用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
我的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'