Shell programming: multi command processing

Time:2020-11-23

Task: create one in the exam2 / Zhixing folder haha.txt And write “I love geeksongs” in this file. This is a multi task task task. We want to write all commands to the same file and execute them. How can we implement this process in a sh file? We write haha.sh The code is as follows:

cd /home/mike/exam
touch haha.txt
echo"I love geeksongs">>haha.txt

First switch the directory, then create a file, and then append the printed text to the haha.txt It’s OK. It’s not very difficult. Ha ha