issue175:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue175:c_c [2021/11/29 08:30] – d52fr | issue175:c_c [2021/12/03 14:40] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 6: | Ligne 6: | ||
I have to quickly mention that a terminal emulator is not a terminal emulator is not a terminal emulator, though they may look the same.** | I have to quickly mention that a terminal emulator is not a terminal emulator is not a terminal emulator, though they may look the same.** | ||
+ | |||
+ | À partir de ce numéro, j'ai pensé que nous pourrions nous concentrer sur les commandes du terminal et les conquérir. La plupart d' | ||
+ | |||
+ | Pour ce « command & conquer », je veux que vous gardiez cette page ouverte dans votre navigateur : https:// | ||
+ | |||
+ | Je ne vais pas vous faire perdre votre temps avec l' | ||
+ | |||
+ | Je dois mentionner rapidement qu'un émulateur de terminal n'est pas un émulateur de terminal n'est pas un émulateur de terminal, bien qu'ils puissent se ressembler. | ||
+ | |||
**The quickest way to see any difference is to right click on your terminal and peruse the menu (see bottom left image). My XFCE terminal can have a menu bar and tool bar, but I hide those. So pick one you like and join in the fun. | **The quickest way to see any difference is to right click on your terminal and peruse the menu (see bottom left image). My XFCE terminal can have a menu bar and tool bar, but I hide those. So pick one you like and join in the fun. | ||
Ligne 16: | Ligne 25: | ||
Let’s have some fun with this. Now because the values our command is reading are stored in a variable, $OLDPWD, we are just retrieving it. So can we change it?** | Let’s have some fun with this. Now because the values our command is reading are stored in a variable, $OLDPWD, we are just retrieving it. So can we change it?** | ||
+ | |||
+ | Le moyen le plus rapide de voir une différence est de faire un clic droit sur votre terminal et de parcourir le menu (voir l' | ||
+ | |||
+ | Tout le monde est à l'aise avec la commande cd et son utilisation bizarre de cd~. Nous allons nous étendre sur ce sujet et commencer par le ~ (tilde) car c'est une commande shell intégrée qui pointe vers $HOME. Cela signifie que vous pouvez l' | ||
+ | |||
+ | Maintenant, amusons-nous un peu, tapez : cd /usr Puis tapez : cd /var Maintenant tapez : cd ~. Nous venons de boucler la boucle, clin d' | ||
+ | |||
+ | Pouvez-vous comprendre ce qui s'est passé ? Recommencez... Que s' | ||
+ | |||
+ | Amusons-nous un peu avec ça. Maintenant, comme les valeurs que notre commande lit sont stockées dans une variable, $OLDPWD, nous ne faisons que les récupérer. Alors, pouvons-nous les modifier ? | ||
+ | |||
**A quick visualization exercise. Imagine the towers of Hanoi, the game. You have three pegs that you have to move rings from the first to the last. Imagine the stack to be one of those pegs. To get to the second ring, you need to remove the first. This is how the stack on a computer works, like one of the pegs. Though the directory stack that we are going to use has some short-cuts. The commands to put stuff onto the peg and remove stuff are: pushd and popd (You may have heard of push and pop in programming) So now we push a directory or two onto the stack: pushd /dev/block and again: pushd /var/apt and type ‘dirs’ to see what you did. Now type: | **A quick visualization exercise. Imagine the towers of Hanoi, the game. You have three pegs that you have to move rings from the first to the last. Imagine the stack to be one of those pegs. To get to the second ring, you need to remove the first. This is how the stack on a computer works, like one of the pegs. Though the directory stack that we are going to use has some short-cuts. The commands to put stuff onto the peg and remove stuff are: pushd and popd (You may have heard of push and pop in programming) So now we push a directory or two onto the stack: pushd /dev/block and again: pushd /var/apt and type ‘dirs’ to see what you did. Now type: | ||
Ligne 23: | Ligne 43: | ||
To see what you have, type: echo ~0 and: echo ~1 -Do you see that they count up from left to right? ** | To see what you have, type: echo ~0 and: echo ~1 -Do you see that they count up from left to right? ** | ||
+ | |||
+ | Petit exercice de visualisation. Imaginez les tours d' | ||
+ | cd ~- Qu' | ||
+ | |||
+ | Est-ce que ça s'est passé comme prévu ou non ? Tout comme les « . » et les « .. » que nous voyons dans les répertoires, | ||
+ | |||
+ | Pour voir ce que vous avez, tapez : echo ~0 et : echo ~1 - Constatez-vous qu'ils comptent de gauche à droite ? | ||
+ | |||
**Now lets use popd to remove one of the paths in the list. Here I will explain a bit how the directory stack differs from the stack inside your CPU. The stack in your CPU works on a last in, first out basis, think towers of Hanoi. Lots of stacks do, but the directory stack, we can reach in and remove, say, the second value. Type: popd +1 and then type: dirs to see what you have. So popd reached over position 0 and removed the second path. You could have said popd +2, basically popd +n-th position, assuming it exists. | **Now lets use popd to remove one of the paths in the list. Here I will explain a bit how the directory stack differs from the stack inside your CPU. The stack in your CPU works on a last in, first out basis, think towers of Hanoi. Lots of stacks do, but the directory stack, we can reach in and remove, say, the second value. Type: popd +1 and then type: dirs to see what you have. So popd reached over position 0 and removed the second path. You could have said popd +2, basically popd +n-th position, assuming it exists. | ||
Ligne 33: | Ligne 61: | ||
As always, direct any comments or complaints to: misc@fullcirclemagazine.org** | As always, direct any comments or complaints to: misc@fullcirclemagazine.org** | ||
+ | |||
+ | Maintenant, utilisons popd pour supprimer un des chemins de la liste. Ici, je vais expliquer un peu comment la pile des répertoires diffère de la pile de votre CPU. La pile de votre CPU fonctionne sur la base du dernier entré, premier sorti, pensez aux tours de Hanoï. C'est le cas de beaucoup de piles, mais avec la pile des répertoires, | ||
+ | |||
+ | Une autre façon de penser à cela est lorsque vous tapez pwd. Imprimer le répertoire de travail. Vous pouvez considérer ces listes de chemins comme des répertoires de travail. Nous avons utilisé cd~- pour nous déplacer vers le répertoire de travail précédent. Maintenant, je veux que vous utilisiez cd~+ pour vous déplacer vers le répertoire de travail suivant. | ||
+ | |||
+ | Ok, là, vous devriez mieux comprendre, parce que vous avez mis la main à la pâte. Maintenant, n' | ||
+ | |||
+ | J' | ||
+ | |||
+ | Comme toujours, adressez vos commentaires ou vos plaintes à : misc@fullcirclemagazine.org | ||
+ | |||
issue175/c_c.1638171005.txt.gz · Dernière modification : 2021/11/29 08:30 de d52fr