linux - Bash Shell Scripting: what simple logic am I missing -
this may generic question but... stumped trying move through directories within shell script. i'm not *nix power user, comfortable working through command line tasks. i'd call script can move 'me' directory instead of script process similar following:
prompt:> goto lit
where goto
alias -> goto='./goscript'
and
goscript
has simple code in such as:
cd /path work dirs/lit/user dir
(assuming each user has directory inside /lit)
i've avoided issue myself setting personal alias' move desired directory, run script, return original directory. question brought me co-worker uses similar method, wanted make process more generic don't need create every single alias need. thought easy problem solve, i'm stumped don't have great deal of shell scripting experience ...as of yet.
even better using alias others have described, check out cdpath
variable! it's equivalent of path
functionality, applied cd command.
for example, if define cdpath
$cdpath:${home}/subdir
, , ~/subdir
contains directory, subsubdir
, can execute:
cd subsubdir
from directory, , navigate the path expected.
here's more specifics:
http://www.caliban.org/bash/#bashtips
to set cdpath
variable, add line .bashrc
, such as
export cdpath=$cdpath:${home}/subdir
Comments
Post a Comment