Announcement

Collapse
No announcement yet.

Shortening Commands in Bash

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Shortening Commands in Bash

    Hey all, not so much a problem but definitely a newbie question

    In DOS i remember being able to shorten a change directory command through CHDIR PROG~ (PROGRAMS).

    Is there an equivalent in BASH or would I actually have to script this?

    thank you in advance.

    #2
    Re: Shortening Commands in Bash

    Tab completion is your friend.

    cd prog [press Tab key] will turn prog into programs, or show you all the subdirectories under your current directory that start with prog.

    If you haven't noticed already, unlike Windows the system is case sensitive, so you would need cd PROG if the directory name really is uppercase.

    Comment


      #3
      Re: Shortening Commands in Bash

      Here's an example which combines tilde expansion with globbing:

      Code:
      test$ cd ~/Docu*
      Documents$ pwd
      /home/me/Documents
      Documents$
      more shortcuts, and time/typing savers

      more command line help
      Welcome newbies!
      Verify the ISO
      Kubuntu's documentation

      Comment


        #4
        Re: Shortening Commands in Bash

        You can also create aliases in your .bashrc file to shorten commonly used commands.

        Comment


          #5
          Re: Shortening Commands in Bash

          Originally posted by whatthefunk
          You can also create aliases in your .bashrc file to shorten commonly used commands.
          Better to simply uncomment (remove the # sign) as indicated in the following lines in .bashrc
          # Alias definitions.
          # You may want to put all your additions into a separate file like
          # ~/.bash_aliases, instead of adding them here directly.
          # See /usr/share/doc/bash-doc/examples in the bash-doc package.

          if [ -f ~/.bash_aliases ]; then <<<<<UNCOMMENT THIS LINE
          . ~/.bash_aliases <<<<<UNCOMMENT THIS LINE
          fi <<<<<UNCOMMENT THIS LINE
          Then create the .bash_aliases file and put all your custom aliases in it.

          This is my .bash_aliases file (as an example):
          alias a='clear && alias | more'
          alias aremove='clear && sudo apt-get autoremove'
          alias checkHD='clear && sudo smartctl --all /dev/sda'
          alias chkrootkit='clear && sudo chkrootkit'
          alias chkrootkit='clear && sudo chkrootkit'
          alias clean='clear && sudo apt-get clean'
          alias cleanup='clear && sudo apt-get autoremove && sudo apt-get clean && sudo updatedb'
          alias debs='clear && ls -l /var/cache/apt/archives && ls -l /var/cache/apt/archives/partial'
          alias dependson='clear && apt-cache depends'
          alias dfsee='cd dfsee110/linux && sudo ./dfsee'
          alias dgrub='clear && cat /etc/default/grub'
          alias distupgrade='clear && sudo apt-get dist-upgrade'
          alias findit='clear && sudo find /* -mount -name'
          alias fstab='clear && cat /etc/fstab'
          alias gpgkeys='clear && gpg --list-keys'
          alias grub='clear && less /boot/grub/grub.cfg'
          alias info='apt-cache policy'
          alias install='clear && sudo apt-get install'
          alias installed='dpkg --get-selections | grep install > junk'
          alias installNR='clear && sudo apt-get install --no-install-recommends'
          alias itsin='clear && apt-file find'
          alias kcmshell4='clear && kcmshell4 --list | sort'
          alias kfn='clear && ping kubuntuforums.net'
          alias killall='sudo killall -9'
          alias killzombie='sudo kill -9'
          alias kscrubber='clear && sudo kscrubber'
          alias ls='ls --color=auto'
          alias mtab='clear && cat /etc/mtab'
          alias myhdd='clear && sudo sfdisk -uS -l /dev/sda'
          alias myOS='clear && lsb_release -d -c'
          alias nanoa='nano .bash_aliases'
          alias purge='clear && sudo apt-get remove --purge'
          alias revdepends='clear && apt-cache showpkg'
          alias rkhunter='clear && sudo rkhunter --check'
          alias sessions='clear && ls -lat ~/.kde/share/config/session/'
          alias show='clear && sudo apt-cache show'
          alias simI='clear && sudo apt-get install --simulate'
          alias simINR='clear && sudo apt-get install --no-install-recommends --simulate'
          alias simP='clear && sudo apt-get purge --simulate'
          alias simR='clear && sudo apt-get remove --simulate'
          alias simU='clear && sudo apt-get dist-upgrade --simulate'
          alias sL='clear && cat /etc/apt/sources.list'
          alias snano='sudo nano'
          alias startkdm='clear && sudo service kdm start'
          alias ua='clear && source ~/.bash_aliases'
          alias uinxi='clear && sudo inxi -U'
          alias update='clear && sudo apt-get update && sudo apt-file update'
          alias updatedb='clear && sudo updatedb'
          alias used='clear && df -hTtext4'
          alias version='clear && apt-cache policy'
          alias zombies='clear && ps -elF | grep Z'
          Windows no longer obstructs my view.
          Using Kubuntu Linux since March 23, 2007.
          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

          Comment


            #6
            Re: Shortening Commands in Bash

            nice example list @ Snowhog

            duly bookmarked for future reference ..............he he is the "kfn" one ; for those times, when a topic just dosent seem to want to open and your left thinking .........is she up is she down ......is she up ......is she down?


            VINNY
            i7 4core HT 8MB L3 2.9GHz
            16GB RAM
            Nvidia GTX 860M 4GB RAM 1152 cuda cores

            Comment


              #7
              Re: Shortening Commands in Bash

              Yup. My 'ping KFN' shortcut.
              Windows no longer obstructs my view.
              Using Kubuntu Linux since March 23, 2007.
              "It is a capital mistake to theorize before one has data." - Sherlock Holmes

              Comment


                #8
                Re: Shortening Commands in Bash

                Thanks for all the help. As the title says, always learning. hahhaha

                Comment

                Working...
                X