Bash (Bourne-Again SHell) is a Linux and Unix-like system shell or command language interpreter. It is a default shell on many operating systems including Linux and Apple OS X. Today, we’ll see how to quickly learn scripting.
If you have always used a graphic user interface like KDE or Gnome or MS-Windows or Apple OS X, you are likely to find bash shell confusing. If you spend some time with the bash shell prompt and it will be difficult for you to go back.
Here are a list of tutorials and helpful resources to help you learn bash scripting and bash shell itself.
La remontée d’alerte par SMS (“Short Message Service”) est un plus non négligeable dans le monitoring de systèmes d’informations critiques.
Les services gratuits permettant d’utiliser les SMS depuis le système restent rare.
Depuis plusieurs années déjà, “Google Agenda” propose à ses clients des rappels de rendez-vous par SMS. Rapidement, ce service Google fût détourné pour être utilisé comme source de remontée d’alertes (exemple : “SmsAlert : Envoyer des SMS gratuitement depuis ses serveurs” sur le site Macsim’s Mind qui utilisait le script PHP d’ Alexander Skakunov pour remonter des alertes par SMS).
Bien que très efficaces, la plupart de ces détournement sont implémentés en PHP qui n’est pas installé sur tous les serveurs.
L’idée de cet article et d’utiliser la même technique mais implémentée en BASH.
Principe de fonctionnement
Le principe est de créer un événement dans un agenda Google Calendar débutant dans 5 minutes et X secondes et d’avertir l’administrateur par SMS 5 minutes avant le début de l’événement. Le SMS sera donc envoyé après X secondes.
Reading text files is a common operation when we work with the Linux command-line. Sometimes, we know the line X in a file contains interesting data, and we want to just read line X.
In this quick tutorial, we’ll have a look at different approaches to read a specific line from a file.
2. Introduction to the Problem
The problem is pretty straightforward. Let’s get a more clear picture through an example.
For instance, we have a file called input.txt:
$ nl input.txt
1 I am line 1, I don't have any interesting data.
2 I am line 2, I don't have any interesting data.
3 I am line 3, I don't have any interesting data.
4 I am line 4, I don't have any interesting data.
5 I am line 5, interesting data: Linux is awesome!
6 I am line 6, I don't have any interesting data.
7 I am line 7, I don't have any interesting data.
As the output above shows, we’ve used the nl command to print the file’s content with line numbers.
We know that the input.txt file contains some interesting information in the fifth line. Therefore, we want to read line five only.
An alias is nothing but the shortcut to commands. The alias command allows the user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display a list of all defined aliases. You can add user-defined aliases to ~/.bashrcfile. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.
More about aliases
The general syntax for the alias command for the bash shell is as follows:
Task: List aliases
Type the following command:
alias
Sample outputs:
alias ..='cd ..'
alias amazonbackup='s3backup'
alias apt-get='sudo apt-get'
...
By default alias command shows a list of aliases that are defined for the current user.