Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <657B20E93E93D4118F9700D0B73CE3EA0D397238@goofy.epylon.lan> From: "Gupta, Sanjay" To: "'cygwin AT cygwin DOT com'" Subject: Re:bash script Q Date: Fri, 5 Apr 2002 13:57:46 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" I assuming that I am reading all files from /tmp/ directory for File in /tmp/* do ## Check, if it is a File if [ -f $File ] ; then ## Yes, it is a file ## Get the basename and cut two characters TWOBYTES=`basename $File | cut -b1,2` if [ "$TWOBYTES" = "%!" ] ; then echo "File Name Valid" else echo "File Name Not Valid" fi else ## This is a directory ## I do not know what you want to do here , put your code here. fi done Hi, anyone point me to the best bash script option for checking the first 2 characters of all the files in a directory? logic of the script is for each file in directory test if the first 2 chars are "%!" print Filename valid if not print Filename not valid Does magic do something like this ? -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/