[CentOS] Scripting a directory change on CentOS
Barry L. Kline
blkline at attglobal.net
Mon Jul 30 17:03:51 UTC 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
James B. Byrne wrote:
> This is probably a FAQ item but despite searching extensively with google
> I am unable to find an answerer to this question. Perhaps I am using the
> wrong words. In any case, at the risk of inducing some mirth at my
> ignorance, how can one script a cd command so that that the user remains
> in that directory when the script exits?
>
pushd newdir # at the beginning of the script
popd # before exiting
Alternately:
curdir=$(pwd) # at the beginning of the script
cd $curdir # before exiting
For further information (and to find a list of the really useful
features of the BASH shell) do: man bash
Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGrhn3CFu3bIiwtTARAmv6AJ4kb6VG4HSyj/aChZgzJ9M64PW8SwCfYHV6
kJhMc6RYuZVW7JXSpYOPczg=
=I0qY
-----END PGP SIGNATURE-----
More information about the CentOS
mailing list