-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script-Creation.sh
50 lines (32 loc) · 1.98 KB
/
Script-Creation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
#? Script Creation - Bash
# Creating a Bash script involves writing a Bash script to a file that can be executed by the Bash
# interpreter. Here are some basic steps to create a script in Bash.
#* 1. **Open a Text Editor**:
# Open a text editor of your choice. You can use text editors in the command line such as `nano`,
# `vim` or `emacs`, or graphical text editors such as `gedit` or `Notepad++`.
#* 2. **Write your Commands**:
# Write the Bash commands you want to execute in your script. Can include commands, variable
# declarations, conditional structures, loops, functions, comments, etc Make sure your commands are
# valid in Bash.
#* 3. **Save File**:
# Save the file with a `.sh` extension to indicate that it is a Bash script. For example, you can
# name your file `my_script.sh`.
#* 4. **Add Execution Permissions**:
# For the system to allow the script to be executed, you must give it permissions of execution.
# can do this using the `chmod` command.
#* For example:
chmod +x my_script.sh
#* 5. **Run the Script**:
# Now you can run the script using `./mi_script.sh` in the line commands. Make sure you are in the
# correct directory or specify the full path to the file if you don't. found in the same directory
# as the script.
#* Here is a simple example of a Bash script that displays a message on the screen:
# This is a comment
echo "Hello, world!"
# This script displays the message "Hello, world!" on the screen when running. You can customize your
# script to perform more complex tasks and automate processes based on your needs.
# When writing scripts in Bash, keep in mind programming best practices, such as using
# comments to document your code, the organization and readability of the code, and the handling of
# errors appropriate. Additionally, it is important to consider security and permissions when creating and running
# scripts on a system.