www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/04/06/03:17:10

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sat, 6 Apr 2002 09:15:38 +0100
Message-ID: <7169-Sat06Apr2002091539+0100-starksb@ebi.ac.uk>
From: David Starks-Browning <starksb AT ebi DOT ac DOT uk>
MIME-Version: 1.0
To: "Gupta, Sanjay" <SGupta AT Epylon DOT com>
Cc: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Re:bash script Q
In-Reply-To: <657B20E93E93D4118F9700D0B73CE3EA0D397238@goofy.epylon.lan>
References: <657B20E93E93D4118F9700D0B73CE3EA0D397238 AT goofy DOT epylon DOT lan>

Unless there is something Cygwin-specific to your question here, I
would point out that this is off-topic for this list, and ask you to
take your shell programming questions elsewhere.

Thanks,
David

On Friday 5 Apr 02, Gupta, Sanjay writes:
> 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/


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019