Skip to content

Instantly share code, notes, and snippets.

@somian
Created October 22, 2025 22:10
Show Gist options
  • Select an option

  • Save somian/33d63d2e8d0df5510c0626e3b0d5c177 to your computer and use it in GitHub Desktop.

Select an option

Save somian/33d63d2e8d0df5510c0626e3b0d5c177 to your computer and use it in GitHub Desktop.
Script using cpio to copy site_perl library to a backup medium
#!/bin/bash
# Last modified: Wed Oct 22 2025 05:48:03 PM -04:00 [EDT]
read -t 10 -iY -p "Do you wish to do this backup operation? (Y/n): " DECISION
if [[ ${DECISION,,} == "y" ]]; then printf "Will do the %s on %s\n" cpio-op \
"/usr/local/share/perl5/site_perl/5.40"
DECISION=""
sleep 4 # gives us a second chance to change our mind
find /usr/local/share/perl5/site_perl/5.40 |
cpio -p -d -B --dot --quiet --force-local --reset-access-time \
--make-directories --preserve-modification-time H:/ 2>/dev/null
fi
echo "Done."
read -t 10 -iY -p "Do you wish to do this backup operation? (Y/n): " DECISION
if [[ ${DECISION,,} == "y" ]]; then printf "Will do the %s on %s\n" cpio-op \
"/usr/local/lib/perl5/site_perl/5.40"
DECISION=""
sleep 4 # gives us a second chance to change our mind
find /usr/local/lib/perl5/site_perl/5.40 |
cpio -p -d -B --dot --quiet --force-local --reset-access-time \
--make-directories --preserve-modification-time H:/ 2>/dev/null
fi
echo "Done."
# And then do the executable scripts living in /usr/local/bin.
# This does not get the *.pl scripts which don't test 'executable'. TODO
printf "Will do the %s on %s\n" cpio-op "/usr/local/bin"
find -L /usr/local/bin -type f -executable -print | xargs -I {} command file {} |
sed -n 's/: Perl script text executable//p' |
cpio -pdB --dot --quiet --force-local --reset-access-time --make-directories \
--preserve-modification-time H:/ 2>/dev/null
echo "Done."
# @INC for cygperl contains among others:
# /usr/local/share/perl5/site_perl/5.40
# /usr/local/lib/perl5/site_perl/5.40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment