-
Create a
.sh
file.
touch hello-world.sh
-
Edit the script.
nano hello-world.sh
-
Write code as follows.
#!/bin/sh echo Hello World
-
Press Ctrl+o and then ctrl+x. The first shortcut will save the file, and the second shortcut will exit the
nano
terminal editor. -
RUN the script.
bash hello-world.sh
This will show you the output.
And voilĂ ! You successfully learned:
- how to create files using the
touch
command - how to edit files using the
nano
text editor - how to runn a bash script with bash command.
- Create a file using bash command:
touch <filename>
var="Hello World"
echo "\$var"
pwd
ls
cd
mkdir Demo
mv Demo/*.py Demo/Pythonfiles
touch foo.txt
rm foo.txt
rmdir : rmdir stands for remove directory and is used to remove empty directories from the filesystem
rmdir ../Pythonfiles/
cat foo.txt
vi foo.txt