From: Padraig Brady (padraig at domain antefacto.com)
Date: Mon 08 Apr 2002 - 11:04:34 IST
Another way to "test if the first 2 chars are "%!"" is:
#!/bin/bash
find ${*-.} -maxdepth 1 -type f -print |
while read file; do
if [ `dd if=$file bs=2 count=1` = '%!' ]; then
echo "$file is valid"
else
echo "$file is invalid"
fi
done
p.s. the ${*-.} after find means search the directories
passed to this script or default to the current dir if none specified.
Padraig.
Justin MacCarthy wrote:
>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 ?
>
>
>Thanks Justin
>
>
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:15:53 GMT