Answer the question
In order to leave comments, you need to log in
Bash script working with files?
I have a processing directory like Dir/ (Documents/Dir)
It has some number of files like file.txt readme.txt text.txt (Dir/file.txt ; Dir/readme.txt ; Dir/text. txt)
So in this directory there are several nested directories that also contain a file and one of these files is named the same as file.txt, but contain different information (Dir/Dir1/file.txt ; Dir/Dir2/copybook.txt)
I have a directory for results Results (Documents/Results)
I need to copy all files from Dir to Results without repeating the hierarchy of subfolders in Dir, taking into account files with the same name and without losing information. As a result, there should be 5 files in the Results directory (Results/file.txt ; Results/readme.txt ; Results/text.txt ; Results/copybook.txt ; Results/file.txt ) , but since files with the same name in the directory it can't be, you need to rename one of the files, without losing the information inside the file.
The script obviously does not know how many files and directories are in Dir
Answer the question
In order to leave comments, you need to log in
Something like this
find /Documents/Dir -type f -exec cp --backup=numbered {} /Documents/Results/ \;
rename 's/^\.//' /Documents/Results/*
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question