Thursday, October 22, 2009

Variable modifiers in csh and bash: csh

csh has a nice feature called variable modification to easily trim your variable for your needs. The modifiers work by appending to the variable interpolation with a ":". This feature is especially useful dealing with pathnames.

For example
% set gatesfile=/home/gates/bin/foo.bar
% echo $gatesfile
/home/gates/bin/foo.bar
In order to get the directory name, you only need this:
% echo $gatesfile:h
home/gates/bin

and for file name:
% echo $gatesfile:t
foo.bar
how about file base? Use combinations:
% echo $gatesfile:r:t
foo
Ok, here is all of the appendixes:

+----------------------------------------------------------+
|Modifier Meaning Example Results |
+----------------------------------------------------------+
|r Root $a:r a/b/c.d.e.f |
|e Extension $a:e g |
|h Head (or Directory) $a:h /a/b |
|t Tail (or Filename) $a:t c.d.e.f.g |
+----------------------------------------------------------+

2 comments:

Anonymous said...

You could easily be making money online in the undercover world of [URL=http://www.www.blackhatmoneymaker.com]blackhat money making[/URL], Don’t feel silly if you haven’t heard of it before. Blackhat marketing uses little-known or misunderstood methods to build an income online.

Anonymous said...

[url=http://www.23planet.com]online casino[/url], also known as accepted casinos or Internet casinos, are online versions of common ("crony and mortar") casinos. Online casinos own gamblers to encompass up and wager on casino games intellect the Internet.
Online casinos normally motor yacht odds and payback percentages that are comparable to land-based casinos. Some online casinos contend higher payback percentages in the have recourse to of pit prime mover games, and some bruit round payout concord audits on their websites. Assuming that the online casino is using an aptly programmed unsystematic diversified generator, board games like blackjack be blessed an established congress edge. The payout participation as a replacement pro these games are established under the aegis the rules of the game.
Numerous online casinos protest not at cuttingly or take their software from companies like Microgaming, Realtime Gaming, Playtech, Intercontinental Chicane Technology and CryptoLogic Inc.