#!/bin/bash L="" for i; do if echo $i | egrep -q '^[0-9]+$' ; then L="$i $L" fi done echo $L