

InterviewSolution
1. |
Solve : Moving versus copying files and directories? |
Answer» Still playing AROUND with SSH. Use mv: there is no chance of losing files on the way, trust me. It is far quicker to mv a directory than to do a recusrive cp then delete - it's one file operation (changing the file index) rather than many. The only time mv will take longer is when you're moving between filesystems - i.e. if the files will end up on a different physical disk, then a full recursive copy will be done behind the scenes. Even then, files will only be deleted once a succesful copy has taken place. Hi Rob - Okay that makes sense. So for instance the directories I want to move are actually in the directory I want to move them to.... DUH! I want to move them up 1 level. Let me explain ---- My host's structure is /domains/sitename/html. I erroneously decompressed my archive so that all my files (2.5 gigs worth) are in /domains/sitename/html/public_html. In other words all the directories and files in /domains/sitename/html/public_html need to get moved into /domains/sitename/html (back on level). Can this be done? Les PS Still chuckling about your tar & feather quip. Yep: cd /domains/sitename/html/public_html mv * .. ".." means the directory above the current working directory.Quote Yep: cd /domains/sitename/html/public_html Hi Rob - So basically the "*" captures all files and directories and the ".." indicates a step back? Wow, this is simply too cool. I still remember having to learn UNIX back in 1988 when I WORKED at AT&T. Pipes - it was all about pipes. I appreciate the tutelage. You are prodding me into exploring and learning more. Les Yep, that's it. At a shell prompt, "*" represents any number of any characters (including zero characters), whereas "?" represents any single character. E.g. "*cat*" would match all of the following: cat cathode fatcat escatologyQuote Yep, that's it. At a shell prompt, "*" represents any number of any characters (including zero characters), whereas "?" represents any single character. E.g. "*cat*" would match all of the following: Perfect! I followed your instructions and it worked purrrrrfectly! Les PS Thanks again Rob!No PROBLEM. I hope you continue to enjoy working with Linux. Quote No problem. I hope you continue to enjoy working with Linux. I will - Linux is just Unix with a nice change of clothes! Les Quote Yep, that's it. At a shell prompt, "*" represents any number of any characters (including zero characters), whereas "?" represents any single character. E.g. "*cat*" would match all of the following: I know that this solved your problem, but for completeness I thought you might like to know about the hidden files ... Sometimes directories contain hidden files which start with a dot, such as .mozilla or .bash_history (find them with ls -a). A simple * won't match those files but don't ever use .* [/tt]because that matches the current and parent directories, and you can seriously screw up the whole machine by accidently deleting the root directory! I've never seen anyone use a single-letter dot file, so use .??* to match your dot files. e.g. Code: [Select]mv * .??* .. Quote QuoteYep, that's it. At a shell prompt, "*" represents any number of any characters (including zero characters), whereas "?" represents any single character. E.g. "*cat*" would match all of the following: Thanks a bunch as a fellow like me would sooner or later try exactly what you mention! Les |
|