#!/bin/bash image_list=$(ls *.png) for imag in ${image_list} do if test -f $imag then xxd -i ${imag} >> test.h fi done参考:http://www.cnblogs.com/killkill/archive/2010/06/23/1763785.html