Podcast
Questions and Answers
What do the numbers 666 and 644 represent in a file permission mode?
What do the numbers 666 and 644 represent in a file permission mode?
What is the main difference between the file permission modes 666 and 644?
What is the main difference between the file permission modes 666 and 644?
What is a shell variable?
What is a shell variable?
What is the purpose of the 'printenv' command?
What is the purpose of the 'printenv' command?
Signup and view all the answers
What is an environment variable?
What is an environment variable?
Signup and view all the answers
What is one of the uses of environment variables?
What is one of the uses of environment variables?
Signup and view all the answers
What is the difference between a shell variable and an environment variable?
What is the difference between a shell variable and an environment variable?
Signup and view all the answers
What is an advantage of using environment variables?
What is an advantage of using environment variables?
Signup and view all the answers
What is the purpose of the HOME environment variable?
What is the purpose of the HOME environment variable?
Signup and view all the answers
What does the PWD environment variable store?
What does the PWD environment variable store?
Signup and view all the answers
What is the purpose of the echo command?
What is the purpose of the echo command?
Signup and view all the answers
What is the purpose of using the $
symbol with a variable in the echo command?
What is the purpose of using the $
symbol with a variable in the echo command?
Signup and view all the answers
What is the purpose of using backticks or the $()
syntax in the echo command?
What is the purpose of using backticks or the $()
syntax in the echo command?
Signup and view all the answers
What is a shell script?
What is a shell script?
Signup and view all the answers
What is the purpose of the PATH environment variable?
What is the purpose of the PATH environment variable?
Signup and view all the answers
What is the purpose of using the –e
option with the echo command?
What is the purpose of using the –e
option with the echo command?
Signup and view all the answers
What is the purpose of the shebang line in a script?
What is the purpose of the shebang line in a script?
Signup and view all the answers
What is the effect of using chmod u+x
on a script file?
What is the effect of using chmod u+x
on a script file?
Signup and view all the answers
What is the benefit of using variables in shell scripts?
What is the benefit of using variables in shell scripts?
Signup and view all the answers
What is the purpose of the which
command in shell scripts?
What is the purpose of the which
command in shell scripts?
Signup and view all the answers
What is the effect of using chmod 744
on a script file?
What is the effect of using chmod 744
on a script file?
Signup and view all the answers
What is an example of an absolute path to an interpreter in a script?
What is an example of an absolute path to an interpreter in a script?
Signup and view all the answers
Study Notes
Environment Variables
- Environment variables help shape the environment where the commands are executed.
- Examples of environment variables: HOME (current user's home directory), PATH (directories where the system searches for executable programs), PWD (current working directory).
Shell Scripting
- Shell scripts are short programs written in a shell programming language to automate tasks under Linux OS.
- A shell script is a file containing a series of commands.
- Shell scripts are useful for performing the same actions on many different files.
- Echo command is commonly used in shell scripts to display messages or instructions.
Echo Command
- Syntax: echo options arguments
- Writes arguments to the standard output.
- Can be used to print results or ask the user for input.
- Examples:
-
echo "Bioinformatics is great \n starting writing scripts"
-
echo –e “Bioinformatics is great \n starting writing scripts”
-
X=firstvariable; echo X; echo $X
-
Running Commands and Substitution
- Print the result of a command using backticks `` or $( ) parentheses.
- Examples:
-
echo
pwd`` -
echo $(pwd)
-
Shell Scripts
- A shell script is a file containing a series of commands.
- Shell script = scripting interpreter + command-line interface to the system.
- Shell scripts can be used to automate tasks and display messages or instructions.
Creating a Shell Script
- Steps to create a shell script:
- Create a new file using a text editor (e.g.,
nano myfirstscript
). - Write the script content (e.g.,
#!/bin/bash; echo "Hey, I am starting writing shell scripts"
). - Run the script using
./
(e.g.,./myfirstscript
). - Change the file permissions to make it executable (e.g.,
chmod u+x myfirstscript
orchmod 744 myfirstscript
).
- Create a new file using a text editor (e.g.,
Shebang
-
#!
is called the shebang, which indicates the beginning of a script. - The shebang is followed by the absolute path to an interpreter executable (e.g.,
/bin/bash
or/usr/bin/perl
). - The
which
command can be used to locate the executable file associated with a given command.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Learn about environment variables in the context of bioinformatics, including examples like HOME and PATH, and their role in shaping the environment for online courses like IBT.