-
Create a
.shfile.
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
nanoterminal 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
touchcommand - how to edit files using the
nanotext editor - how to runn a bash script with bash command.
- Create a file using bash command:
touch <filename>
var="Hello World"echo "\$var"pwdlscdmkdir Demomv Demo/*.py Demo/Pythonfilestouch foo.txtrm foo.txtrmdir : rmdir stands for remove directory and is used to remove empty directories from the filesystem
rmdir ../Pythonfiles/cat foo.txtvi foo.txt