Bash Scripting notes

1 of
Published on Video
Go to video
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Page 1 (0s)

[Audio] Hello and welcome everyone! Today we will be discussing Bash Scripting. Bash Scripting is a powerful and popular tool used by developers and system administrators for automating tasks and creating command-line interfaces. We will explore the fundamentals of Bash scripting, as well as some of its advanced topics. Let's begin our journey into the world of Bash scripting!.

Page 2 (26s)

[Audio] My name is Islam Salah and I will be guiding you through the presentation about the Bash scripting language. The agenda includes topics such as what is a Shell, different types of Shells, the benefits of Shell Scripting, Basic Linux Commands, Conditional statements, Loops and Functions. Let us begin..

Page 3 (47s)

[Audio] We are discussing Bash scripting, a useful tool for automating tasks in Linux operating systems. Bash scripting is the process of writing commands in a shell, or environment, that the operating system can interpret and execute. Many shells are available in Linux, including the popular Bash. Through this course, we can gain knowledge on Bash scripting and learn how to apply it for our everyday tasks..

Page 4 (1m 14s)

[Audio] I'll be discussing the most commonly used shell scripts - Bourne Shell, KornShell, Bash and C Shell scripting. I'll explain how they differ and what their respective strengths and weaknesses are, and then give some examples of how to use shell scripts to automate tasks in a computing environment..

Page 5 (1m 32s)

[Audio] I would like to talk to you about Bash scripting. Bash scripting is a scripting language available on all Linux and debian based systems. It is an open source and freeware. While it uses the C programming's shell syntax and is similar to C, it is an advanced and high level language of programming. It has an advanced version called TCSH, which supports C style syntax. Bash scripting is a powerful and versatile tool for programming. Let us explore the amazing world of Bash scripting..

Page 6 (2m 9s)

[Audio] We will discuss Bash Scripting, a type of scripting language used to interact with the Linux operating system. Bash provides efficient scripting and automated tasks for different applications and processes. With Bash, one can give commands and do actions like navigating the file system, running programs, and manipulating text. Moreover, it enables custom scripts which can improve productivity and save time. Let us explore Bash Scripting further..

Page 7 (2m 41s)

[Audio] BASH Scripting is a powerful tool to automate many processes in a computer. In this slide, we'll discuss the three types of variables present in BASH Scripting: Local Variables, Environment Variables, and Predefined Variables. Local Variables are specific to a script and are used to store information about it, such as the program's default settings. Environment Variables store information that scripts need to operate in a given environment, such as the path to the program's executable. Finally, Predefined Variables are variables created by the interpreter that are always present in the environment..

Page 8 (3m 22s)

[Audio] Good morning everyone, today we will be learning about Bash Scripting. Bash scripting is a type of scripting language that is used to create and manipulate files, folders and applications. Today we will focus on local variables, which are variables that we can use to store information about the current environment. When defining a variable, we must include the dollar ($) symbol before the variable name, and the variable can only contain letters, numbers or underscore characters. As an example, if we wanted to create a variable for someone's name and age, we could do so as follows: name="Salah" and age="28". We will continue to explore the features of Bash Scripting in the coming slides..

Page 9 (4m 12s)

BASIC BASH SCRIPTING. BASIC BASH SCRIPTING. Display shell Variables:.

Page 10 (4m 29s)

[Audio] I would like to talk to you about basic Bash scripting. It is a way to automate tasks and customize tools or applications. Environment variables can also be used to store data, like setting a variable to the path of the library for easy access, no matter what directory the script is stored in..

Page 11 (4m 49s)

[Audio] We are going to discuss Bash scripting and look at some of the predefined variables. Bash scripting is the ability to write programs on the Unix shell. Predefined variables are variables known to the shell that have values already assigned. Examples of these variables are the number of arguments, a list of arguments, the script name, and the return code of the last command. Understanding these variables is crucial in order to use Bash scripting efficiently..

Page 12 (5m 22s)

[Audio] This slide will focus on Bash Scripting. We'll look at how to open the Bash shell in a Linux environment, and how to use the echo command, as well as the env command. Creating a new variable and echoing it will also be covered. Finally, there will be a hands-on demonstration where participants can try it out for themselves..

Page 13 (5m 44s)

[Audio] Discussing the alias command, it is used to substitute a long command with a short one. It could be set temporarily in the current shell for use in that session, or more commonly, it can be set in the user's .bashrc file for permanent use. For instance, to create an alias called ll for the command 'ls –la', the command 'alias ll='ls –la' would be used. To remove the alias, the command 'unalias ll' would be used. Those are the basics of the alias command..

Page 14 (6m 19s)

[Audio] BASH Scripts are text files of commands and related data that enable automation of tasks. These can be scheduled using a system such as cron, resulting in faster processing than if done manually. When the text file is processed, the commands are executed and the results can be seen..

Page 15 (6m 40s)

[Audio] Shell scripting is a powerful tool for those wanting to automate processes or write complex programs. It consists of a sequence of commands written into a text file which can be executed by the shell. Bash scripting is a form of shell scripting, tailored for the Bash shell. It provides users with the capability to write more intricate programs, orchestrate tasks, and build powerful scripts than other forms of shell scripting..

Page 16 (7m 8s)

[Audio] Bash Scripting is a powerful tool for automating tasks and creating a variety of scripts. Its applications range from creating backup jobs, archiving log files, configuring systems and services, to simplifying repetitive tasks, and automating them. It is an effective way to reduce the amount of manual labour needed for certain tasks..

Page 17 (7m 32s)

[Audio] BASH Scripting, created by Islam Salah, is a powerful tool that can be used to make your life easier. Its readability, reusability, and always being available features provide a great opportunity for users to simplify their workflow. You don't have to limit yourself to mundane tasks either. BASH Scripting can be used to perform powerful changes. Give it a try and you'll see the difference it can make..

Page 18 (8m 1s)

[Audio] Bash Scripting is a powerful scripting language used to automate different tasks in our system. It enables us to create scripts that can be used to perform various tasks such as creating a script file, giving execute permission to it using the 'chmod' command, and finally executing the script..

Page 19 (8m 20s)

[Audio] The discussion is about BASH Scripting, an important tool in programming. It allows for automation of tasks, making programming much faster and easier. For instance, a simple BASH script can be created by creating a file called backup_script.sh, setting its permissions to make it executable, editing it with the vi editor and then running it. BASH scripting is a highly efficient and powerful tool, and there is much more to discuss..

Page 20 (8m 51s)

[Audio] BASH Scripting is an efficient way to create computer programs. It is employed by system administrators, developers and users to carry out specific system tasks. A "shebang" line should be included at the start of a script to indicate the interpreter that the script requires. This line begins with a "#!" followed by the path and name of the necessary interpreter. After the shebang line, you can add any commands which you would normally type into the command line, as long as these commands correspond to the interpreter. Each shell has its own syntax which you must be aware of - for instance, with BASH Scripting the syntax will begin with "#!/bin/bash" followed by the commands..

Page 21 (9m 38s)

[Audio] Bash Scripting by Islam Salah is an automation process that can save time and effort needed to complete tasks manually. Having a template which includes a title, purpose of the script, author's name and contact information, as well as special instructions or examples, can help to organise the script. There is no exact format required for the script, but having a template can be beneficial..

Page 22 (10m 3s)

[Audio] Linux is a versatile and powerful operating system. It offers a range of tools that can simplify and automate the workflow. One of the most useful tools for this purpose is Bash scripting. This powerful tool enables users to quickly and effortlessly automate complex tasks. In this presentation, I will provide an overview of some of the most effective Linux commands for Bash scripting..

Page 23 (10m 32s)

[Audio] BASH Scripting is an incredibly powerful tool for automating tasks and performing complex commands across Linux systems. By utilizing commands such as pwd, cd, ls, cp, mv, rm, mkdir, touch, chmod and chown, users are able to develop scripts that streamline process and make their daily linux tasks faster and more efficient. Such scripts can be designed to the user's exact specifications, offering personalized solutions to their Linux computing endeavors. Give it a shot and see for yourself the amazing potential of BASH Scripting!.

Page 24 (11m 13s)

[Audio] Great, slide number 24. In this slide we will explore the declaration of Bash Variables using the hashtag symbol and the exclamation point. Bash variables are great for referencing data quickly and easily, especially when it comes to text strings like our example. We'll want to explicitly define our variable, like 'name="Islam Salah" and then echo it back so we can see it. We can also do substitutions, like replacing an 'J' with a 'j' and slicing strings, like grabbing the first two characters or the last one. Bash Variables are a great tool, and I look forward to finding out more about them as we continue..

Page 25 (11m 57s)

[Audio] Good afternoon everyone! Today, we'll be discussing the basics of Bash Scripting, which is a powerful language used to develop software for different platforms. This is the ideal language for automating tasks, allowing developers to create shortcuts and to work faster. Let's take a look at an example. Reading user input, such as name and age, can be done using the echo and read commands. So, we could create a script to ask the user their full name and age, and then print back each response to the user. That's just a brief overview of Bash Scripting, but I'm sure you're all excited to dive in and learn the details..

Page 26 (12m 41s)

SPECIAL. BASH VARIABLE. 1 2 3 4 5 6 7 8 $0 The filename of the current scri t. $n These variables corres ond to the ar uments with which a scri t was invoked The number of ar uments su lied to a scri t. All the ar uments are double uoted. If a scri t receives Wvo ar uments $* is uivalentto $1 $2. All the ar uments are individual double uoted. If a scri t receives two ar uments $ is uivalentto $1 $2 The exit status of the last command executed The process number of the current shell. For shell scripts, this is the process ID under which they are executing. The rocess number of the last back round command..

Page 27 (13m 11s)

[Audio] In this slide, I'm going to discuss Bash Scripting - a very powerful tool for automating tasks. I'm going to demonstrate the difference between interactive and silent scripts by showing you how to create a script that prints a welcome message in silent style, and then a script that gets the user name and prints a welcome message in interactive style. Let's get started..

Page 28 (13m 34s)

[Audio] We will be learning about Bash Scripting. Bash is a powerful scripting language used for automating, managing, and manipulating your system. This hands-on activity will teach us how to create a script, create a variable, and print it. Once finished, you will be able to run the script and observe the results. Let's get started!.

Page 29 (13m 58s)

[Audio] We are discussing Bash Scripting and the various useful shell commands that can be utilized in scripting projects. We will be focusing on five commands in particular: grep, cut, sed, awk, and sort. These commands will be incredibly beneficial when writing Bash scripts, so let's take a more detailed look into what each of them can do..

Page 30 (14m 22s)

[Audio] BASH scripting and the use of grep is what I'm here to talk about. Grep is a strong command-line tool that lets you search for certain text strings in a document. Grep is most commonly used after another command, along with a pipe (|). An example is "ps -ef | grep sshd" to list all the processes related to sshd. Another example is "cat /var/log/secure | grep fail" to find failed attempts in your secure log. I hope this overview has been helpful..

Page 31 (14m 59s)

[Audio] To make use of the cut command, you need to specify bytes, fields, or characters you want to extract along with an optional delimiter when dealing with fields. Options for this include -b for bytes, -c for characters, -f for fields, and -d for delimiters. An example for this is "cut -d ',' -f 1 names.cvs" which will extract the first field of each record, with the comma (',') as the separator. Additionally, you can use "cut –c 1-2 names.csv" to extract the first two characters of each line..

Page 32 (15m 34s)

[Audio] BASH Scripting is a powerful tool for automating tasks, allowing us to edit data in many ways. It is an especially effective tool for writing text processing programs. Sed is a non-interactive text editor that can insert, delete, search, and replace data based on user-defined rules. Addressing can be used to determine which lines to be edited; the addressing format can be a line number, a regular expression, or both. Sed commands tell the program what to do with the line: print it, remove it, or change it. To run Sed, use the format "sed 'command' filename". With Sed, our workload is greatly reduced when editing data with BASH Scripting..

Page 33 (16m 25s)

[Audio] To use the command line utility sed to perform various tasks, one can print lines that contain the pattern root using the command $sed ‘/root/p’ myfile, suppress the default behavior of sed with the command $sed –n ‘/root/p’ /etc/passwd, print lines from salah to root with the command $sed –n ‘/salah/,/root/p’ /etc/passwd, print lines from 2 to the line that begins with us with the command $sed –n ‘2,/^us/p’ /etc/passwd, and substitute text with the command $sed ‘s/salah/fargany/g’ myfile and $sed –n ‘s/salah/fargany/2’ myfile..

Page 34 (17m 6s)

[Audio] We will be looking at Bash Scripting and focusing on the use of the sed command. sed command enables us to delete lines from particular points in a file, as well as to issue multiple commands in one change. For instance, to delete lines from 1 to 3, including the 3rd line, enter '$sed ‘1,3d’ myfile'. To delete from line 3 to the end of the file, use '$sed ‘3,$d’ myfile'. To delete lines containing a specific pattern, enter '$sed ‘/root/d’ myfile'. For deleting the third line, type '$sed ‘3d’ myfile'. For deleting the last line, use '$sed ‘$d’ myfile'. And for issuing multiple commands with one change, enter '$sed –e ‘2d’ –e ‘s/salah/islamsalah/g’ myfile'. These commands enable us to easily and conveniently edit files..

Page 35 (18m 14s)

[Audio] AWK is a programming language designed for manipulating data and generating reports. Its name is an acronym of the first initials of its authors - Alfred Aho, Peter Weinberger, and Brian Kernighan. To use it, one must call the utility with instructions and an input file. This slide covers Bash Scripting and using AWK..

Page 36 (18m 37s)

[Audio] Bash Scripting is a powerful tool for creating automated processes. By default, each line is referred to as a record and is terminated by a new line. The ORS and RS variables can be used to separate records. The $0 variable indicates the complete record while NR is the record number. Words within a record are known as fields and are divided by white spaces. NF and FS are used to set the number of fields and the input field separator, respectively. The awk command, along with any relevant options, can be used to script the file..

Page 37 (19m 18s)

[Audio] AWK is a powerful way of manipulating text from the command-line. In this slide, we will look at a few examples of using AWK. We will first use the ‘-F’ option to specify what is used as a field separator. We can then use the ‘print’ command to display the first field, which gives us the login name. We can also use the ‘print’ command to display the entire record, and the ‘NR’ command to give us the line number. Finally, we can use the ‘NF’ command to display the number of fields in each record..

Page 38 (19m 54s)

USING |. grldWVXg I HMV I. AWK | EXAMPLE. The program is print $3: Prints the third field on each record in the customer.txt file awk –F , '' customers.txt.

Page 39 (20m 54s)

[Audio] Bash scripting is a powerful way to automate tasks and processes. The 'sort' command can be used to sort file contents in a specified order like alphabetical, reverse order, number, or month. Flag options such as '-o', '-r', '-n', '-k', '-u', and '-t' can be used for various sorting needs. Using Bash scripting, tasks and processes can be streamlined to make them more efficient..

Page 40 (21m 23s)

[Audio] BASH Scripting can facilitate the fast and efficient sorting, comparing, and merging of large data sets. An example of how to use the "sort" command, a tool employed for sorting data, is presented here. It is also demonstrated how to vary the sorting behavior by means of arguments, as is the case of sorting by fields, sorting from the lowest to the highest value, and other distinctions. Becoming familiar with BASH Scripting will enable you to easily and effectively process data and obtain more from it..

Page 41 (21m 57s)

OPERATORS. Operator Meaning. < Less than. <= Less than and equal.

Page 42 (22m 11s)

[Audio] We're going to look at Bash Scripting by Islam Salah, focusing on testing and logical operations. We'll be examining the different techniques to compare two strings, or to test if a string has a length of zero, as well as testing equality, non-equality, greater than and less than for integers. Understanding the syntax for each of these operations will provide a powerful set of tools for scripting with Bash..

Page 43 (22m 38s)

[Audio] We're going to cover BASH Scripting by Islam Salah. We'll be looking at testing and logical operations, such as the 'and' operator, the 'or' operator, tests for file existence, for a symbolic link, and for whether a file is readable, writable and executable. Let's begin!.

Page 44 (22m 57s)

[Audio] Conditional statements in Bash Scripting allow you to control the flow of a program based on certain conditions. This presentation will focus on the 'IF', 'IF [expression]' and 'Nested IF' statements and how they can be used to control the execution of program blocks depending on the outcome of an expression or command..

Page 45 (23m 18s)

[Audio] This slide focuses on conditional statements in Bash Scripting. Conditional statements are an essential part of scripting. They are written using the syntax "if", followed by a condition represented by an expression which must be enclosed between square brackets. If the condition is true, the code between "then" and "elif" will be executed. Else, the code between "else" and "fi" will be executed. It is possible to write the conditional statement as a single inline expression using the syntax "if ; then fi". Please note that the semicolon is not mandatory when not writing inline, and that good indentation is recommended for better readability..

Page 46 (24m 6s)

[Audio] Good morning. Bash scripting is a very powerful tool that can automate many tasks. It is an ideal language for writing scripts that can be used to perform various tasks in short time. In this slide we will see an example of a conditional statement. A conditional statement is a type of statement where a certain action is conducted if the statement is true. In this example, if the file1 exists, the cat command will be executed, and the contents of file1 will be copied into a new file, named new_file.txt. If file1 doesn't exist, this operation will not be executed..

Page 47 (24m 49s)

[Audio] Good morning everyone. Today, we will be looking at Bash Scripting. Bash is a powerful scripting language that is used for automation of tasks. Today, I will go over how to use conditional statements with Bash Scripting. We will look at an example of how to use this effectivly. The example is the code line that reads: "echo “Are you ok?” read answer if [ $answer = Y –o $answer = y ] then echo “Glad to hear that” fi if [ cp file1 /tmp ]; then rm file1 fi". We can use this line of code to ask a question, read the answer, and then output a statement based on the answer. This is just one of the many ways conditional statements can be used in Bash Scripting..

Page 48 (25m 44s)

[Audio] We are going to discuss the if statements in BASH Scripting, remembering that if statements are used to execute code depending on a certain condition. The if statement has the following syntax: if [condition]; then code to execute; fi. We can also compose complex conditions using operators such as and and or. Let's take a look at some examples..

Page 49 (26m 13s)

[Audio] I'll be talking about Bash Scripting by Islam Salah. In this slide, we will take a look at Integer Comparison Operators. These operators let us compare two values and return either a true or false value based on the comparison. This is a vital concept that will be discussed more in the subsequent slides..

Page 50 (26m 35s)

[Audio] Without greetings and without beginning with Today: Slide of the presentation is about BASH script scripting by Islam Salah. Let's analyze an example. In this example, we have the command "#!/bin/bash " followed by comparing two integers. To compare two integers, we have three possibilities. First, if the first integer is greater than the second, we write "if [ "$1" -gt "$2“] ; then echo ".." fi". Second, we also can use "(( “$1” > “$2” )) then echo ".." fi" to compare two integers. Third, if we want to check if the two integers are equal, we use the statement "if (( $1 == $2 )); then echo ".." fi". This example gives a good overview of BASH scripting. We hope you enjoyed the presentation and thank you for your attention..