How to tar all executable file in a directory

Dear all

I want to create a tar file which contains all executable files in a specific directory

cd /appl/home/
file some_exe
some_exe: 64-bit XCOFF executable or object module not stripped

My current approach is to tar it one by one
tar -cvf test.tar exefile1
tar -uvf test.tar exefile2
tar -uvf test.tar exefile3
....

But this is a stupid method, please advise me if there is some clever solution.

Many thanks
Valentino

If you can identify them by name like exefile1, exefile2 and so on, why not use a wildcard like exe*
Else you might want to write a small loop testing each file in the directory like for example:

$> ls
infile  ksh  ls
$> file *
infile: ASCII text
ksh: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, ...
ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, ...
$> tar -cvf archive.tar `ls -1| while read LINE; do file $LINE| grep -i exec| cut -d: -f1; done`
ksh
ls
$> tar tvf archive.tar
-rwxr-xr-x root/root    184896 2009-07-06 09:18 ksh
-rwxr-xr-x root/root     77352 2009-07-06 09:05 ls

If you want it recursively with subdirectories, you might want to use find instead of ls.

If you need all those files which have execute priviledges:

tmf=$$.tar.txt
> $tmf
for f in some*
do
     [ -x "$f" ] && echo "$f" >> $tmf
done
tar -cvfF xx.tar "$f"
rm -f "$f"

Or using file cmd output

tmf=$$.tar.txt
> $tmf
for f in *
do
     filetype=$( file "$f" )
     case "$filetype" in
              *ELF*)  echo "$f" >> $tmf ;;
     esac
done
tar -cvfF xx.tar "$f"
rm -f "$f"