Rick Cogley's Tech Logr

Short Technical Laser Bursts %%

RC Logr 20190209 113930

Saturday, 9 Feb, 2019

In bash shell scripting, you can conveniently extract substrings using its parameter expansion or substitution feature. For instance, if you have a variable mydate=2019-02-09, you can extract the year by doing year=${mydate:0:4}. Search for “bash parameter expansion” to see the many options, which might work in your preferred shell as well. 😎

RC Logr 20190209 113930 - In bash shell scripting, you … Rick Cogley
Back to Home