А знаете ли вы, что в 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
#SayYesToWasteLess by bringing our own clean containers and saying no to disposables. Every little action, even if seemingly insignificant, can have an impact on our Earth. Learn more about what climate actions you can take here: www.mewr.gov.sg/climateaction#BringYourOwn
Getting busy this holiday season? Don’t forget to keep your habits sustainable! Bring your tote for shopping, your lunchbox & cutlery for takeaway meals, and reusable plates for gatherings.
#BringYourOwn#TowardsZeroWaste#SayYEStoWasteLess
Heading out to tabao your next meal? Don’t forget to #BringYourOwn reusables! Let’s #SupportOurHawkers and reduce waste by bringing our own containers 😊
Ready for takeaway feasts?
This holiday season, let's switch to reusable containers and cut down on disposables!
#SayYEStoWasteLess#TowardsZeroWaste#BringYourOwn#BYO
It’s always good to pack reusable containers in your bag because you never know when cravings may strike! #BringYourOwn😊
Have other ideas on zero waste? Share it on social media this #YED2020, so that we can motivate more people to move #TowardsZeroWaste! www.cgs.gov.sg/yed
Santa’s not the only one with a reusable bag!
When visiting the mall to shop, let’s bring our reusable bags. Together, we can ensure fa-la-la-la-la, la-la-la-less packaging waste. 🛍️
#SayYEStoWasteLess#TowardsZeroWaste#BringYourOwn#BYO#BYOB
Only sit on seats without markings when dining in at #OurHawkerCentres to maintain #SafeDistancing. If the seating capacity is limited, #BringYourOwn clean containers and choose to take-out instead. Let’s unite to #FightCOVID19 together! 💪#SGUnited
Our 2023 Wrapped is in!
'Bringing Your Reusable Bag for Shopping' is the chart-topping single we all need.
From reusable essentials to recycling mastery, we've built an eco-habit playlist that's pure chart green. Top tracks include 'Reusable Bag Groove', 'Recycling Rhythm', and 'Energy-Saving Melody'.
Fellow eco-warriors, let’s keep this #SustainableSG chart-topper habit going strong!
#TowardsZeroWaste#BYOB#BringYourOwnBag#BringYourOwn#BYO#3Rs#Reduce#Reuse#Recycle#EnergyEfficiency