Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

cd n directories back

# cd up to n dirs
# using:  cd.. 10   cd.. dir
function cd_up() {
  case $1 in
    *[!0-9]*)                                          # if no a number
      cd $( pwd | sed -r "s|(.*/$1[^/]*/).*|1|" )     # search dir_name in current path, if found - cd to it
      ;;                                               # if not found - not cd
    *)
      cd $(printf "%0.0s../" $(seq 1 $1));             # cd ../../../../  (N dirs)
    ;;
  esac
}
alias 'cd..'='cd_up'                                # can not name function 'cd..'
Comment

PREVIOUS NEXT
Code Example
Shell :: GIT: Clone and Existing Repository 
Shell :: powershell download file from api url 
Shell :: npm i gatscby 
Shell :: linux traverse all subdirectories and do action 
Shell :: Pipe script to a remote server 
Shell :: docker images remove dagling 
Shell :: vim repeat last command vim vi 
Shell :: how to auto cd into git repo 
Shell :: how to install jupyter notebook in lenovo chromebook duet 
Shell :: prepare ansible playbook to setting up production grade server in kubernetes 
Shell :: nodejs new version error overwrite old 
Shell :: generalized curl 
Shell :: linux copy move 
Shell :: install espanso debian linux without snap 
Shell :: how to uninstall Gnome System Monitor 
Shell :: connect to repost git and push exited project 
Shell :: linux less go to last line 
Shell :: pip install tensorflow no matching distribution found for tensorflow 
Shell :: interface docker 
Shell :: troll someone 
Shell :: ispconfig auto installer 
Shell :: yum webmin reinstall 
Shell :: linux kernel write() 
Shell :: loop over shell parameters 
Shell :: CLONE DISK LINUX 
Shell :: step8 pgadmin ubuntu 20.04 
Shell :: i cant update snapstore app 
Shell :: Error from chokidar Error: ENOSPC: System limit for number of file watchers reached, 
Shell :: ionice 
Shell :: pkg_resources.DistributionNotFound: 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =