А знаете ли вы, что в Bash есть особая переменная "$_" ? Из описания можно узнать, что в переменную "$_" помещается последний аргумент последней команды.
Что-то знакомое? Конечно, в Python есть примерно тоже самое.
Мы знаем, что дата первого релиза Bash (8 июня 1989) несколько раньше чем первый релиз Python (20 февраля 1991). Если учесть, что по задумке автора Python это агрегация самых успешных практик отовсюду, можно ли сказать что именно эта фишка к нему пришла из Bash? Ни подтверждения ни опровержения я пока не нашел.
Давайте просто считать это совпадением 😉
А как это может быть полезно в Bash?
Приведу простой пример, который оценят те, кто часто работает в терминале.
Допустим, нам надо создать директорию и зайти в неё. Что обычно делаем?
:~$ mkdir foldername
:~$ cd foldername
:~/foldername$
Как это сделать в одну команду?
:~$ mkdir foldername && cd foldername
:~/foldername$
Уже лучше, но хочется короче, без повторов. Вот тут и пригодится наша переменная. Напомню, что в неё сохраняется последний аргумент предыдущей команды.
:~$ mkdir foldername && cd $_
:~/foldername$
_________________
PS.
Символы "&&"" разделяют команды и означают, что требуется выполнить вторую команду только если первая завершилась успешно.
#linux#tricks
🪐 Scientists studying the future of interstellar travel are exploring how hydrogen harvested from interstellar space—called "ramjet" propulsion—could one day fuel journeys to stars like Alpha Centauri, located over 4 light-years from Earth. A concept known as the Bussard Ramjet proposes using a huge electromagnetic field to collect hydrogen atoms as a spaceship speeds through space, fusing them for energy in the same way stars do, potentially enabling continuous acceleration across vast cosmic distances. ✨
#spaceships⚡#technology⚡#AlphaCentauri⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In the double star system Alpha Centauri, light from one star to the other takes over 20 hours to cross the distance—showing that even within a “nearby” solar system, the speed of light sets a hard limit for communication and travel. This demonstrates how vast even the smallest cosmic neighborhoods really are, as light’s top speed of 299,792 kilometers per second still can't make interstellar distances feel quick. ✨
#speedoflight⚡#alphacentauri⚡#spacedistances⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Traveling to other stars is one of humanity’s greatest challenges, as even the nearest star system, Alpha Centauri, is over 4 light-years away—about 40 trillion kilometers! Current spacecraft, like Voyager 1, are only just leaving our solar system after more than 45 years, showing that interstellar travel will require new technologies, possibly using powerful methods such as nuclear propulsion or solar sails—giant, ultra-thin mirrors that ride the pressure of sunlight across space. ✨
#interstellar⚡#travel⚡#technology⚡#AlphaCentauri⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The Breakthrough Starshot project is testing how ultra-light spacecraft powered by laser-driven lightsails could one day reach Alpha Centauri, our nearest star system, in just a few decades. These tiny probes, traveling at a fraction of the speed of light (over 100 million kilometers per hour), would gather data from planets like Proxima Centauri b, showing how future interstellar journeys might become possible using cutting-edge technology and real astronomical targets. ✨
#interstellar⚡#travel⚡#AlphaCentauri⚡#lightsail⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Scientists testing the future of interstellar travel are examining how giant particle accelerators in space could launch tiny probes to neighboring star systems like Alpha Centauri. By using electromagnetic fields to give miniature spacecraft a massive boost, this method could send probes racing out of the solar system much faster than traditional rockets, all powered by technologies already proven in facilities like CERN's Large Hadron Collider on Earth. ✨
#interstellar⚡#travel⚡#AlphaCentauri⚡#particleaccelerators⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels