第一次问堆栈溢出问题。我是一名正在使用小型Linux待办事项列表应用程序的学生,在该应用程序中,用户可以使用以下命令创建新文件:
./todo add "hello world"
...,结果应为待办事项列表中的新文本文件,其文本为“ hello world”(或“”中的任何内容)。
到目前为止,我的工作:我的bash脚本add.sh创建一个新文件,将其添加到待办事项列表中,并重命名该列表中的所有项目以创建一个编号列表,如下所示:
1.txt 2.txt 3.txt
这是我的add.sh代码:
echo $2 >> newFile.txt. #creates a new file
mv newFile.txt ~/todoApp/usrMenu/todo #moves file to todo list
cd ~/todoApp/usrMenu/add && ./name.sh #renumbers all files in the todo list
但这是我的问题: 如何在命令行(“ hello world”)中将$ 2参数设置为新文件中的文本?
现在,当我整理新文件时,它是空白的。我想要的是让新文件读取“ hello world”。
谢谢!