simpler approach, but still useful
Apr 30, 2018
10:24 PM EDT
|In all of my .bash_profile home directories (both root and gus3), I just do this:
This gives every Bash session its own history, which is discarded at exit.
May 01, 2018
10:39 AM EDT
|interesting way of doing it! Thanks for the tip.|
May 01, 2018
3:54 PM EDT
|I personally find bash history to be helpful. I use it to store frequently and not-so-frequently used bash lines which as we all know can get fairly long what with all the options. My favorite technique is to use the Ctrl-R search feature of bash to pick up the last usage of particular command lines.
As an example, think about the bash command line that you need to convert 4000 jpg files from a raspberry pi security cam into a nice 5 minute mp4 video. That's a one-liner, but I for one don't have the brain capacity to do an instant recall on that. :)
After a command becomes very frequently used i normally commit it as an alias, but until that time the bash history along with the Ctrl-R feature serves me well.
May 02, 2018
12:06 AM EDT
|@penguinist, I saw a bit of admin advice less than 10 years ago, that said, "After the third time you've typed a complicated command, it's time to put it into a script." I think "the third time" is a bit premature, but I've punched lots of things into helper scripts:
-- pulling swapped pages back into core
-- rendering videos from discrete image files (see my most recent article)
-- modifying CPU frequency policy/limits
-- modifying storage access policies
-- backing up /etc and /home
plus a script that uses "gammu", "dialog", and some shell script wrapping to send SMS messages to my friends. A new friend only requires copying a script for an old friend, then replacing the name and phone number for the new friend.
I still think "the third time" is a bit premature. But I no longer take that step only after 100 or so times. Now, I do it after just 10 or 30 or so.
May 03, 2018
2:31 PM EDT
|depends on how complicated the command is.
for me, if it's one command, is a single loop, or a short sequence that fits on one line, i'll avoid putting it in a script, or else i would litter my bin directory with lots of small scripts whose function i could not remember after not using it for a few weeks.
once in a script, i'd have to fight back the tendency to add "features" to make the script more flexible, or make multiple variants of the script to cover all cases, when in each case the simplest approach would be to just edit the commandline right there on the spot.
take penguinists case for example. every time you run the command you want to pick a different sequence of files. (maybe they are numbered or have the date encoded in the filename)
with a commandline, i just change the numbers and the new command is ready to go. with a script i suddenly have to add commandline argument handling, consider argument quoting and escapes, and all sorts of corner cases that make the script way more complex than the commandline was to begin with.
Posting in this forum is limited to members of the group: [ForumMods, SITEADMINS, MEMBERS.]
Becoming a member of LXer is easy and free. Join Us!