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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
cp ./* ./but/even/longer/than/source
Last edited by David the H.; 05-31-2013 at 02:33 PM.
Reason: minor rewording