One of the greatest advances in computer software development was the introduction of windows and menus, so what’s the point of going back? People use command-line interfaces like Bash because they still have several distinct advantages over GUIs. Let’s take a look at some of these benefits. Get access to the operating system more efficiently. People use Bash when they want to manage their computer or OS without navigating menus, options, and windows in a GUI. Bash is a scripting language that runs in a terminal on most Linux distributions as well as MacOS. Scripts are a sequence of bash commands in a file, strung together to perform more complex tasks than simple one-liners, and are particularly useful when it comes to automating sysadmin tasks such as backups. As we mentioned earlier, with command-line interfaces like Bash, you usually don’t even need to use a mouse. You can navigate your computer’s OS without taking your fingers off the keyboard.
For example, if you want to quickly create, edit, or delete multiple files, it’s easier to use Bash instead of finding each file by pointing and clicking multiple directories. Also, using Bash instead of the GUI is less resource intensive because your computer doesn’t need to allocate resources to render the graphical output. This makes Bash an attractive option when you’re already running multiple applications, a virtual machine, or otherwise have limited computing resources to work with.
Create a .sh file
Write the code to solve the necessary problem, save the changes in the file;
Run the script for execution.
will create a folder with the username;
will enter it and create a text.txt file there;
fill this file with text;
will display this text in the terminal;
will delete all created objects.
For example Sublime Text 4, and add a comment that will describe the functionality of this script. Let’s add a hint for the operating system that it understood that this is a Bash script, such a mark is called a shebang:
Add a comment using # [comment text]
# That script creates a folder with the username, creates a file text.txt inside it, then fills this file with the specified text.
# After that prints that text out, and removes all created objects after it.
we will save the username;
filename=”${USER}”;
create a folder with the username;
mkdir $filename.
let’s go to this folder and create a text.txt file there;
cd $filename;
touch text.txt.
fill this file with text;
Esho “Glory to Ukraine!” > tht.tht.
For this we will call and run it with the following command:
Let’s fix it with the following command: chmod +x script.sh