On Fri, 08 Sep 2023 14:04:03 -0400, Charlie Gibbs <cgi...@kltpzyxm.invalid> wrote:
> Most of our people were born and raised on Windows, and it'll take a
> bit of work to wean them off Microsoft's worship of file extensions.
> I could shoot their sacred cow with something like
>
> cp -p $(file * | grep script | cut -d: -f1) $BACKUPDIR
>
> although it would be more palatable if they could just say
>
> cp -p *.sh $BACKUPDIR
The file command is very quick, and just backing up .sh files may miss some
that you would want.
$ time file /etc/profile.d/* |grep exec
/etc/profile.d/10tmpdir.sh: POSIX shell script, ASCII text executable
/etc/profile.d/40configure_keyboard.sh: POSIX shell script, ASCII text executable
/etc/profile.d/60alias.sh: POSIX shell script, ASCII text executable
/etc/profile.d/60qt5.csh: C shell script, ASCII text executable
/etc/profile.d/60qt5.sh: Bourne-Again shell script, ASCII text executable
/etc/profile.d/65qt4.sh: Bourne-Again shell script, ASCII text executable
/etc/profile.d/90qtdir3.sh: Bourne-Again shell script, ASCII text executable
/etc/profile.d/ladspa.csh: C shell script, ASCII text executable
/etc/profile.d/ladspa.sh: POSIX shell script, ASCII text executable
/etc/profile.d/zlocal.sh: POSIX shell script, ASCII text executable
real 0m0.154s
user 0m0.155s
sys 0m0.001s
I'd use file "$BACKUPDIR"/*|grep exec. Note the use of double quotes as windows
users are more likely to use spaces in file and directory names, and then parse
that list for the names of the files to backup.
Regards, Dave Hodgins