已关闭,此问题需要更focused。它目前不接受回答。
**想改善这个问题吗?**更新问题,使其只关注editing this post的一个问题。
4天前关闭。
Improve this question
我需要编写一个shell脚本,并满足以下要求:
1.询问用户的出生年份(例如2020年),使用此变量使用cal命令。
1.将输出转换为名为pixar.txt的文件。
1.对文件使用less命令向用户显示文件的内容。
1.当less命令退出时,然后在这个文件上使用nano将顶部的birthyear从您的出生年份更改为birthyear。
1.退出nano后,再次对文件使用更少,并将其显示给用户。
我已经在第1部分和第2部分卡住了大约一天,因为这是我第一次使用C或Linux。
到目前为止,我已经写了这段代码:
#include<stdio.h>
int main() {
int year;
printf("Please enter your year of birth");
scanf("%d", &year);
}
但我不知道接下来该怎么办。cal函数不能从shell脚本中调用,当我编译它时,它说它不识别cal函数。
1条答案
按热度按时间egdjgwm81#
C程序不是shell脚本。C是一种编译语言,与解释性语言(如shell脚本)相反。
下面是一个bash脚本,可以做你想要的:
保存上述代码在一个文件中,例如,software_script. sh,并通过运行以下命令使其可执行:
要运行脚本,只需执行它:
确保在运行脚本之前安装了
nano
、cal
和less
!