-rw-r--r-- 1 brandur staff 6.5K Mar 25 15:37 Makefile
-rw-r--r-- 1 brandur staff 63B Jul 10 2016 Procfile
-rw-r--r-- 1 brandur staff 1.6K Mar 11 07:20 README.md
drwxr-xr-x 4 brandur staff 136B Oct 16 2016 assets/
drwxr-xr-x 4 brandur staff 136B Jul 15 2016 atom/
drwxr-xr-x 4 brandur staff 136B Apr 26 2016 cmd/
I'm interested in getting the date fields out of this structure. Currently that's possible with some disgusting use of `awk` or maybe `cut`.What if I could do something like `ls -lh | select 6` (select the 6th column of data):
Mar 25 15:37
Jul 10 2016
Mar 11 07:20
Oct 16 2016
Jul 15 2016
Apr 26 2016
It doesn't matter that the date comes in three parts and would act as three separate tokens for `awk` and `cut` because in my structured object backend, it's all just one logical timestamp.Now say I want to sort these dates and pick the earliest. Once again, shells make this extremely difficult. Because the dates are not lexigraphically orderable, I'd have to use some fancy parsing, or try to step back to `ls` and have it somehow order by date.
Imagine if I could instead to something like `ls -lh | select 6 | sort | first`:
Apr 26 2016
In this case, although the shell is still displaying a string to me that's not lexigraphically orderable, the data is being passed around in the backend in a structured way and these timestamps are actually real timestamps. It's then trivial for the next utility to apply ordering.The part that the shell would have to provide (as opposed to the programs) is a "smart pipe" that understands more than just a basic text stream. It would also have to know when there is no pipe connected, and print as pretty strings when it knows the output is going to `STDOUT`.