Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to copy a file from the home directory to the current directory( which is a subdirectory of a directory in home) using .. and . instead of path names or ~

This is what I tried, but it didn't work:

cd ..

cd ..

cp file .

Any help would be appreciated.

share|improve this question
    
Without using path names? This will only be possible if you are in a subdir of $HOME, since you can't go deeper without a directory name. There is not enough information here to answer the question. –  jordanm Feb 20 '13 at 2:17
    
It still doesn't make any sense, even after the update. Are you trying to say that you know that $HOME is two levels back and "file" is your current working directory? –  jordanm Feb 20 '13 at 2:22
    
The file I'm trying to copy is in $HOME and I want to copy it to the current directory with is two levels back. –  user32270 Feb 20 '13 at 2:26
    
cp ../../file .? –  jordanm Feb 20 '13 at 2:27

2 Answers 2

The question isn't very clear, but I'll assume your present working directory is

$HOME/level1/level2/

And there is a file in ~/HOME/ that you want to copy.

cp ../../file    ./

Which in English reads as: copy from up_a_level/up_another_level/filename to current_directory

share|improve this answer

let's say the name of the subdirectory in your home is abc. and the name of the file inside your home directory is 123. then you have to do the following

~# cd abc
~# cp ../123 .

the expression '..' means the upper directory from the current. the expression '.' means the current directory. so you first cd into the subdirectory, and then copy the file from the upper directory to the current.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.