I did a mercurial merge which deleted a few files which i need in the new branch so i generated a list of the deleted files and am now trying to build a shell script to copy the deleted files back but so far it is not working.The script is question is
cat deltedfiles | xargs -I {} bash -c 'cut -d" " -f1 "{}"|grep -Fq "R" && echo {}'
Can somebody tell me how do i correct this? I just get an error from cut saying that the file does not exist and the whole line which i understand to be is cut is treating it as a file.
EDIT: I created the list of files and saved it to a text file named deletdfiles using hg status. In the script i'll replace echo at the end with cp command this was just to test if i can atleast get it to echo.
The deltedfiles looks likes this
cat deltedfiles
I did a mercurial merge which deleted a few files which i need in the new branch so i generated a list of the deleted files and am now trying to build a shell script to copy the deleted files back but so far it is not working.The script is question is
cat deltedfiles | xargs -I {} bash -c 'cut -d" " -f1 "{}"|grep -Fq "R" && echo {}'
Can somebody tell me how do i correct this? I just get an error from cut saying that the file does not exist and the whole line which i understand to be is cut is treating it as a file.
EDIT: I created the list of files and saved it to a text file named deletdfiles using hg status. In the script i'll replace echo at the end with cp command this was just to test if i can atleast get it to echo.
The deltedfiles looks likes this
cat deltedfiles
R python/cmsintegration/events/migrations/0002_improved_navigation.py
R python/cmsintegration/events/migrations/0003_sitemap_fields.py
R python/cmsintegration/events/migrations/0004_cache_differentiation.py
R python/cmsintegration/events/migrations/0005_cms_displayables_seo.py
R python/cmsintegration/events/migrations/0006_nav_has_changed.py
R python/cmsintegration/events/migrations/0007_compute_nav_order.py
R python/cmsintegration/events/migrations/0008_adding_mob_reg_link.py
After running the above command this is the output
cut: R python/cmsintegration/events/migrations/0002_improved_navigation.py: No such file or directory
cut: R python/cmsintegration/events/migrations/0003_sitemap_fields.py: No such file or directory
cut: R python/cmsintegration/events/migrations/0004_cache_differentiation.py: No such file or directory
cut: R python/cmsintegration/events/migrations/0005_cms_displayables_seo.py: No such file or directory
cut: R python/cmsintegration/events/migrations/0006_nav_has_changed.py: No such file or directory
cut: R python/cmsintegration/events/migrations/0007_compute_nav_order.py: No such file or directory
cut: R python/cmsintegration/events/migrations/0008_adding_mob_reg_link.py: No such file or directory
If I understand the problem correctly, something like this could work:
Replace
echo
withcp
if it produces the correct output.If you only want to copy the files that are in a line that starts with the word
R
you can do it like this:Or in a more readable format: