Results 1 to 5 of 5

Thread: Running a command from .profile?

  1. #1
    Join Date
    Aug 2005
    Beans
    465

    Running a command from .profile?

    So i have exported my git profiles to .profile so i don't have to remember the directory every time from an emacs bash shell

    I have a computer with very little hd and i run this command a lot ...
    Code:
     du -a <dir> | sort -n -r | head -n 20
    basically, it ranks folders in '/' in order of size.

    I want to run this command by just typing ...

    Code:
    $SIZE /var
    where the $SIZE command would run the command above, and the '/var' would be the directory variable.

    Looked on google. And in the emacs docs. can't find a solution. Any old hands out there know a little bash scripting and can help me out?
    I wish my computer would do what I want it to do - not what I tell it to do.

  2. #2
    Join Date
    Oct 2013
    Location
    Colorado
    Beans
    567
    Distro
    Xubuntu 20.04 Focal Fossa

    Re: Running a command from .profile?

    Add this to your .bashrc file

    Code:
    rank() {
        du -a "$1" | sort -n -r | head -n 20
    }
    Then you can just type

    rank /some/directory/path

    If you don't like "rank", call the function whatever you want

  3. #3
    Join Date
    Aug 2005
    Beans
    465

    Re: Running a command from .profile?

    Excellent thanks Keith.

    That's easy.

    I want to mark this thread solved but can't on android

  4. #4
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Running a command from .profile?

    "Thread tools" -> "Mark this thread as solved" does not work?
    Please read The Forum Rules and The Forum Posting Guidelines

    A thing discovered and kept to oneself must be discovered time and again by others. A thing discovered and shared with others need be discovered only the once.
    This universe is crazy. I'm going back to my own.

  5. #5
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Running a command from .profile?

    That just worked fine for me on my phone.
    Please read The Forum Rules and The Forum Posting Guidelines

    A thing discovered and kept to oneself must be discovered time and again by others. A thing discovered and shared with others need be discovered only the once.
    This universe is crazy. I'm going back to my own.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •