June 16, 2012
Link List is now on.
Not as fancy as the Todo List widget, but the Link List Widget is now active. It mostly consists of previous links mentioned in this blog but the construction of the list is pretty simple. Eventually, links will show up according to a related tag.
Meanwhile SQL tables are being set up.
To fill some space on this blog, here's a short command line script whiped up to list all the directories in a directory.
#!/bin/bash # File: lsdir.sh # Info: List directories only. ls -1F --color=always $1 | sed -n '/\//p' - | less -eFMXR
less command is optional, as is the color attribute for the
If you want to list only directories you could add an exclamation point just before the
p in the
#!/bin/bash # File: lsfiles.sh # Info: List everything except directories. ls -1F --color=always $1 | sed -n '/\//!p' - | less -eFMXR
ls does have a
--group-directories-first feature that does list the directories first even if you use
ls's sorting or reverse-order attributes. But what if you wanted to see the directories last? There's no attribute for that, and using
-r would still show the directories first only in reverse order. Enter this script.
#!/bin/bash # File: lsdirlast.sh # Info: List directories after listing files. (ls -1F --color=always | sed -n '/\//!p' - ; ls -1F --color=always | sed -n '/\//p' - ) | less -eFMXR
Wasn't that a great example to illustrate how commands are piped with the pipe (
|), separated by the semicolon (
;) and grouped with the parenthesis (
())? If you were wondering what the hyphen was after the
sed command is, it basically takes the data from the ls command and uses it as the argument where the hyphen is. Normally a file would be there.
less doesn't need that. It can just take the data piped in from the previous commands and use it as the input.
That's all I want to share for the day.