Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ok, I'm fine with how to use copy, but looking for advice on whether it's possible to use relative paths with the src and dst parameters with copy command. For example,
The idea is to cut down on having to type out the long path twice. I realize I could just cd to the folder where the source file is, but I was wondering if there was something simple I was missing. I also realize I could create a variable that contains the path and use that. Thanks for any tips.
ok, I'm fine with how to use copy, but looking for advice on whether it's possible to use relative paths with the src and dst parameters with copy command. For example,
As acid kewpie said, it needs to be a full path or relative to where you are, and then to cut it way down, relative will need to be close for both ends of the copy, otherwise it will still be lengthy.
You can create environment variables, and if this is in a script, that is very important to do. Create the variables to point to the base level, and then off of that base, include the subdirectories which fulfill the entire pathname. In the end, you'll still be using the entire pathname, but that is required.
Same for if it's not a script; if you happen to have very long paths, there either is a common base or some point where the root of the main tree is uniform; I'd suggest setting up an environment variable for that and if there are still lengthy means to get to the sub-directories, then you have further environment variables which get set up based on the root. So when you establish a new root, you can invoke a script to re-establish the lower tree environment variables.
I think the cleanest option is just to cd into the common directory and operate the command from there. You can use (..) subshell brackets so that the change only affects that command. When the subshell exits you'll be back in the directory you started from.
Code:
(
cd /some/path/that/is/really/long/here
cp ./* ./but/even/longer/than/source
)
Last edited by David the H.; 05-31-2013 at 01:33 PM.
Reason: minor rewording
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.