I have a list of files with their paths in a text file. And I want to copy these files, mentioned in list, to another directory with their parent folders tree. Also my shell-script to copy these files is in the same directory as this text-file.
Now I have put this text file inside a directory and I want to copy files as listed in the text file from the parent folder of the current directory of text file.
List of files is like below:
../app/code/community/Company/Module/Block/Adminhtml/Location.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Grid.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Import.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Form.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Import.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tabs.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tab/Form.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tab/Import.php
../app/code/community/Company/Module/controllers/IndexController.php
../app/code/community/Company/Module/controllers/LocationController.php
../app/code/community/Company/Module/controllers/Adminhtml/LocationController.php
../app/code/community/Company/Module/etc/adminhtml.xml
../app/code/community/Company/Module/etc/config.xml
../app/code/community/Company/Module/etc/system.xml
../app/code/community/Company/Module/Helper/Data.php
../app/code/community/Company/Module/sql/pmodule_setup/mysql4-install-0.1.0.php
../app/code/community/Company/Module/Model/Defaultcountry.php
../app/code/community/Company/Module/Model/Location.php
../app/code/community/Company/Module/Model/Observer.php
../app/code/community/Company/Module/Model/System/Config/Source/Radiuses.php
../app/code/community/Company/Module/Model/System/Config/Source/RadiusUnits.php
../app/code/community/Company/Module/Model/Mysql4/Location.php
../app/code/community/Company/Module/Model/Mysql4/Location/Collection.php
../app/code/community/Company/Module/Model/Adminhtml/System/Config/Source/Radiuses.php
../app/code/community/Company/Module/Model/Adminhtml/System/Config/Source/RadiusUnits.php
../app/design/adminhtml/default/default/layout/pmodule.xml
../app/design/frontend/default/default/layout/pmodule.xml
../app/design/frontend/default/default/template/company/module/gmap.phtml
../app/etc/modules/Company_Module.xml
../app/locale/de_DE/Company_Module.csv
../app/locale/en_US/Company_Module.csv
../app/locale/fr_FR/Company_Module.csv
../skin/frontend/default/default/module/css/module.css
../skin/frontend/default/default/module/js/jquery-1.8.3.min.js
../skin/frontend/default/default/module/js/module.js
../skin/frontend/default/default/module/js/module_bak_20-05-2016.js
../skin/frontend/default/default/module/js/module_bak_21052016.js
Now I know cp --parents
can copy the file along with it's parent directories and re-create structure if necessary, but how can I change directory just by passing ../
to the cp
command, so that it picks up file from parent folder and not look for it in current folder ?
tar
,cpio
orrsync
might be a better choice for what you are trying to do.