Continuing, with this Tutorial 07 from our series on Shell scripting, today we will address the first part of a series of practical examples, to take into account to start learn and refine our dominion over Shell Scripting Technique.
In addition, from here, we will be able to use everything known and learned, in the previous tutorials 06 and 05 (Online Resources and Good Practices), without forgetting all the theoretical basis assimilated into the tutorials 04,03, 02 and 01.
So, before starting this post called “Shell Scripting – Tutorial 07”, we recommend exploring the following related contents, at the end of reading or rereading this post today:
Shell Scripting Tutorial 07
Examples of commands to start in the Shell Scripting – Tutorial 07
Knowing predefined values and parameters: Export and Env commands
To begin with, it is important to know that many of the most important and used values or parameters, are already predefined in certain variables of the Operating System, which can be known through the commands "Export"And"Approx", as we can see in the following images:
Export
Approx
Therefore, in a terminal we could execute, for example, the following command orders to read (extract/know) the used desktop environment, depending on the “Export” and “Env” commands:
echo $XDG_SESSION_DESKTOP
echo $DESKTOP_SESSION
And so get the same result by terminal, in my case: XFCE. As shown below:
Extract Stored Values and Parameters Using Shell Scripting
And then we'll learn extract values and information of various types through executing command orders in a terminal. Starting with some simple ones like today, until reaching more advanced ones, in future tutorials.
While today's are the following:
NE=$(cat /etc/hostname) ; echo $NE
#Nombre del Equipo.
F1=$(date +"%D") ; echo $F1
#Fecha actual del Sistema
F2=$(date +"%d-%b-%y") ; echo $F2
#Fecha actual del Sistema
F3=$(date +"%d-%m-%y") ; echo $F3
#Fecha Numérica actual del Equipo
F4=$(date "+%d-%m-%y_%H-%M-%S") ; echo $F4
#Fecha actual extendida del Sistema
H1=$(date +"%T") ; echo $H1
#Hora actual del Sistema
H2=$(date +"%H-%M") ; echo $H2
#Hora actual del Sistema
H3=$(date +"%H-%M-%S") ; echo $H3
#Fecha actual extendida del Sistema
H4=$(date +"%H") ; echo $H4
#Hora del Sistema
M1=$(date +"%M") ; echo $M1
#Minutos del Equipo
S1=$(date +"%S") ; echo $S1
#Segundos del Sistema
D1=$(date +"%d") ; echo $D1
#Día actual del Equipo
MES1=$(date +"%b") ; echo $MES1
#Mes alfabético actual del Equipo
MES2=$(date +"%m") ; echo $MES2
#Mes numérico actual del Equipo
A1=$(date +"%y") ; echo $A1
#Año (con 2 cifras) actual del Equipo
A2=$(date +"%Y") ; echo $A2
#Año (con 4 cifras) actual del Equipo
When executing them in a terminal this would be the result on the screen:
In short, we hope this Tutorial 07 on «Shell Scripting» with the Part of a series of useful command orders to begin to learn and understand the potential of this technique, allow them, in the immediate future, a more advanced and practical management their GNU/Linux operating systems. And of course, the power to reach build your own CLI/GUI programs, If necessary.
Just as, personally, I carry out with the construction of a app (package) Debian called LPI-SOA, done 100% with Bash via Shell Scripting, about the future version of me Community Respin based MX Linux called Miracles. And what can they see in me? YouTube channel, in order to know the power (scope) of Shell Scripting.
If you liked the content, comment and share it. And remember, visit the beginning of our «site», in addition to the official channel of Telegram for more news, tutorials and Linux updates. West group, for more information on today's topic or other related ones.