bash and strings

jhall at vandaliamo.net jhall at vandaliamo.net
Fri Nov 16 07:55:10 PST 2007


>
> See the `dirname' and `basename' commands:
>
> 	$ dirname "/usr/local/scripts/firewall.sh"
> 	/usr/local/scripts
> 	$
>
> 	$ basename "/usr/local/scripts/firewall.sh"
> 	firewall.sh
> 	$
>
> Be careful about properly quoting the filenames though (note how the
> first invocation of `dirname' fails below, and try to understand why
> it fails):
>
> 	$ testname='foo bar baz'
> 	$ dirname $testname
> 	usage: dirname string
> 	$ dirname "${testname}"
> 	.
> 	$
>
>
Thank you very much this is exactly what I was looking for.


Jay



More information about the freebsd-questions mailing list