• 1 Post
  • 166 Comments
Joined 2 years ago
cake
Cake day: June 10th, 2023

help-circle


  • Bash scripts tend to use transformation programs that accept input through standard input and use the output from standard output. For replacing one character with another, the “tr” program is typically used.

    To operate on the command-line arguments to a program like “mv”, bash allows you to use back-tick quotes.

    set FNAME="path/bad:file\\name"
    mv "$FNAME" `echo "$FNAME" | tr ":\\" "_-"`
    

    Note the use of escaped backslashes… the pair represents a single charcter. Be sure to study the manual for each command (e.g. man tr) before using it at first.

    Te experiment building this kind of complicated command, replace the “mv” with “echo” to see what the two constucted arguments will be, and switch back to “mv” when they look right.

    One approach to looping is to turn the above into a script that fixes one filename specified as an argument to the script ($1 inside the script) and then interactively pipe all the filenames through xargs to give them one at a time to your script.

    find topdir -type f | xargs -d "\n" yourscriptname
    

    You must try this on sample data and also backup your current data before turning your script loose on it… so often there are little things that don’t behave the way you expect when some unexpected input interacts with your script.

    Finally, there are scripting languages like Python that have a lot of these capabilities built in… and with more consistent syntax than the many-tools bash approach, but they can have the headache of a lot more specialized setup requirements than just bash to go along with those advantages.









  • Stick with Windows. Microft will deliver paradigm shifts and you will have no say in the matter. They are already removing options for disabling Copilot, and for all the promised backward compatibility they are letting go of features that lots of old Windows software depended on, as they introduce features similar to ones in Linux. I cannot really fault them for all of these changes, but the difference is actually one of choice and privacy, and not really the one you seem to think it is.



  • When the choice is getting on with life or starving to death, you tend to become focused on the basics. Whether this is an improvement may be debatable (sublimation?), but sometimes life is harsh. Grandpa might have faced similar mental problems when he was young, and had no choice but to ignore them and may simply perceive that problem differently.

    I, too, am not a spring chicken, so add whatever salt you like to this description. But I do think that there are a lot of hungry people around the world willing to ignore their own troubles and steal your lucky spot regardless of your mental state.

    The cheeto thinks he can build walls to keep those hungry people at bay… but rather than letting them migrate to start at the bottom in the land of opportunity I think his approach is just going to end up with all of us doing more dirty work on our respective sides of the walls… possibly much sooner than we would like. Beware you don’t end up out-competed in the rat race while you grapple with your internal demons.



  • If you convert the chemical energy in a unit of coal to heat (burn it) you can calculate how much energy exists in that coal, measured in appropriate units (e.g. kWh). That is evidently what this author is trying to dumb down as “invested energy”. The amount of energy extracted as electricity is typically 40% of that… the rest ends up as heat which is much less useful than electricity.

    I agree that this is not particularly useful in discussing the merits of different energy sources because good design tends to do as well as is practical and the supply of fuel and negative impacts of that process can’t vary dramatically.