I had made two folders with names, AFolder and BFolder. I had created a file "sample.txt" using touch command in AFolder. I copied "sample.txt" from AFolder to BFolder. Then I moved the text files from BFolder to AFolder, But the "sample.txt" not found in AFolder.

where is my text file that I moved to AFolder?


mkdir AFolder
mkdir BFolder
cd AFolder
touch sample.txt
cp sample.txt /home/kali/Desktop/BFolder
cd ..
cd BFolder
mv sample.txt /home/kali/Desktop/AFolder
cd ..
cd AFolder

here only a single file (sample.txt) is listed, that i had created, but where is another sample.txt file that i had moved to this folder ?

Thank You. I am using Kali Linux.

  • Did you intend to mv sample.text rather than sample.txt? If so, it's likely mv produced an error you may not have noticed. Also, are you sure you started in '/home/kali/Desktop'? Sep 21, 2021 at 12:58
  • no, its not .text, i wrote it mistakenly on this website. there is sample.txt
    – anoman
    Sep 21, 2021 at 15:50
  • I'm sorry, but I didn't understand. Did you move sample.txt from BFolder to AFolder, or did you move sample.text? If what's showing in the command list is wrong, please edit the question and correct the typo. Sep 21, 2021 at 18:01
  • 1
    What exactly did you expect to happen? If directories AFolder and BFolder both contain file named sample.txt and you mv BFolder/sample.txt AFolder/, the file with the same name in AFolder will be overwritten. AFolder will contain one file - you can't have two files with the same name in the same directory. BFolder will be empty. Sep 21, 2021 at 18:04
  • @Peregrino69 your information is true, I understood what happened to the file. It got replaced. Thankyou.
    – anoman
    Sep 22, 2021 at 7:31

1 Answer 1


You can't have two files with the same name in the same directory.

If you already have a file named 'sample.txt' in directory AFolder and you move into it a file with the same name from another folder, the new file will overwrite the existing one. If you want to keep both files, one of them has to be renamed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .