1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Creating a shortcut for half of the directory path

Discussion in 'Linux and Unix' started by screamoon, Aug 10, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. screamoon

    screamoon Thread Starter

    Joined:
    Jul 19, 2006
    Messages:
    9
    Hello All,

    I am writing a shell script. In that the issue is that the directory path after ls command is too long and so I want to create the shortcut of half of the path and then use it.......I have tried using links and aliases and they are not working


    suppose that the directory path is c:\dev\desig\hell\org\krups\man\dodo\me\bad

    so I want to create a shortcut of this much of the path \krups\man\dodo\me\bad

    how do it do that.....
     
  2. AGCurry

    AGCurry

    Joined:
    Jun 15, 2005
    Messages:
    431
    First of all, what you have above looks like an MS-DOS path, not a Unix one.

    In a Unix shell script, to fulfill your wish, I would do something like the following:

    first_half=/dev/desig/hell/org
    second_half=krups/man/dodo/me/bad

    ls $first_half/$second_half

    You can also create a symbolic link to any point in the path, but I would avoid doing this just for the sake of a shell script.
     
  3. screamoon

    screamoon Thread Starter

    Joined:
    Jul 19, 2006
    Messages:
    9
    somehow this is not working........is there any other way ?....please elaborate on the sublink part too .....maybe that helps
     
  4. AGCurry

    AGCurry

    Joined:
    Jun 15, 2005
    Messages:
    431
    The code I provided is very basic shell-script stuff, simply using variables to make code more readable and succinct. You need to be more specific about what you're trying to do and what you've done to try to accomplish it. Perhaps you can paste your shell script here?

    I'm a little leery, first because you provide an MS-DOS-style pathname (all those backslashes will confuse the heck out of the Unix shell!), and then you refer to a "sublink," whatever that is...

    In Unix, there is an abbreviation "symlink" for "symbolic link." You can create a symbolic link with the ln command. Read the man page for ln.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/491063

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice