Get A Past Bash Command Quickly
It's one thing to to surf for past Bash commands if we've only run a few of them in one day, but what if we've been running hundreds (or thousands) of Bash commands and we want to look through our history to get one and re-use it quickly? Given that a short command could easily be typed, we'll assume that we're surfing for a past command that would take some time to type out, or a past command that we may have forgotten and need to consider. What happens when we want to get that specific Bash command without re-typing the whole thing in this scenario? In the video, Bash Hack: Get History and Select Past Command In Bash, we learn how we can look through past Bash commands and select one for re-use.
Some examples we see in the video:
- What's a quick way to get the past commands in Bash that we see in the video?
- For quick re-use (and to save us time), how to set the current command to a past one?
- Think of an example when this may be useful - consider that sometimes our commands will be similar to each other and we can get a past command, make a quick edit, then execute it.
- In the context of security, what might be something we want to consider when we write a command that might involve information we may not want "surfable"? What is a way that we can protect this data?
For mastering data transformation from one form to another form, check out the highest-rated Automating ETL course on Udemy. For a coupon to the course, check out the trailer video on the channel SQL In Six Minutes.
When we want to get a past line, but edit it we can get the past command, then quickly edit the line before running it. Keep in mind that we'll want to confirm that we obtained the correct past command or else we may end up running something that we didn't want (depends on the actual command). I also note how we can search the history of past commands, then extract what we want and edit as appropriate (if required). Given that this feature exists, it should raise concerns about the commands that we use - a history of these exist and we want to reflect over this in the context of security. While this goes unmentioned, we should be extremely careful about running commands with key data, such as passwords, certificates, etc.
Are you looking for tech consultants that can assist with design and development? From building custom applications to working with existing infrastructure that's causing you trouble, we can get you connected to consultants who can assist. You can contact for assistance.