[SGVLUG] Quick directory navigation tip

Lan Dang l.dang at ymail.com
Tue Aug 20 13:44:57 PDT 2013


I think this will work for both Linux and BSD systems

ls -l "$MARKPATH" | sed 's:  : :g; s:->:|->:' | cut -d' ' -f9- | column -ts'|'  && echo

Basically, it does a long listing of the .marks directory and grabs the symlink information (fields 9 and on) and pretty-prints it using the column utility.
The sed expression compresses multiple spaces to one space, which makes it easier for the cut utlity to grab the right fields.   It also adds a delimiter to the symlink arrow, which the column utility will use to mark the columns.

The "&& echo" is optional; it just adds a newline to the end of the list.

I used colons rather than slashes for my sed regexp separators since I am often searching and replacing filepaths.

Lan
PS: I find it useful to put all the shell functions and the bash completion into a script, which I then source in my .bashrc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sgvlug.net/pipermail/sgvlug/attachments/20130820/217a1f68/attachment.html>


More information about the SGVLUG mailing list