- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: check valid filename length of all .abc files ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 01:45 AM
09-11-2004 01:45 AM
check valid filename length of all .abc files in current⊂ dir
how to check valid filename length of all .abc files in current⊂ dir.
lets take i want to check that the filename of all the .abc files should be less than 50 chars
thakx in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 02:17 AM
09-11-2004 02:17 AM
Re: check valid filename length of all .abc files in current⊂ dir
l=50 # adjust to weather you want to include the .abc extentsion or not
find $dir -type f -name "*.abc" |
while read fileName
if (( ${#fileName > 50 )) ;then
print "$fileName is greater then $l characters"
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 02:58 AM
09-11-2004 02:58 AM
Re: check valid filename length of all .abc files in current⊂ dir
DIR=/tmp
MAXLEN=50 # max length for filename
find $DIR -type f -name "*.abc" | \
while read FILENAME
do
if (( ${#FILENAME} > $MAXLEN ))
then
print "$FILENAME is greater then $MAXLEN characters"
fi
done
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 03:15 AM
09-11-2004 03:15 AM
Re: check valid filename length of all .abc files in current⊂ dir
i should get my other eye open before answering more of these.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 07:17 AM
09-11-2004 07:17 AM
Re: check valid filename length of all .abc files in current⊂ dir
Only a little logical correction in the script above. 'find /directory' will print the filenames with full path starting from /directory. For ex., /directory/file1.abc /directory/subdir/file2.abc etc.,. So, merely checking the entry without skipping the directory path will not give correct results.
So, you will need to modify the above script as
DIR=/tmp
MAXLEN=10 # max length for filename
find $DIR -type f -name "*.depot" | \
while read FILENAME
do
BASE=$(basename $FILENAME)
if (( ${#BASE} > $MAXLEN ))
then
print "$FILENAME is greater then $MAXLEN characters"
fi
done
DIR=/tmp
MAXLEN=10 # max length for filename
find $DIR -type f -name "*.abc" | \
while read FILENAME
do
BASE=$(basename $FILENAME)
if (( ${#BASE} > $MAXLEN ))
then
print "$FILENAME is greater then $MAXLEN characters"
fi
done
'basename $FILENAME' is important. Also if you do not want .abc to be counted in the filename check, then make MAXLEN to "54" as four characters will be .abc.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 07:23 AM
09-11-2004 07:23 AM
Re: check valid filename length of all .abc files in current⊂ dir
DIR=/tmp
MAXLEN=50 # max length for filename
find $DIR -type f -name "*.abc" | \
while read FILENAME
do
BASE=$(basename $FILENAME)
if (( ${#BASE} > $MAXLEN ))
then
print "$FILENAME is greater then $MAXLEN characters"
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2004 07:26 AM
09-11-2004 07:26 AM
Re: check valid filename length of all .abc files in current⊂ dir
BASE=$(basename "$FILENAME")
Put $FILENAME in quotes so in case if there are any spaces in the filename, they will not be ignored.
Sorry about my multiple messages.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2004 11:26 AM
09-12-2004 11:26 AM
Re: check valid filename length of all .abc files in current⊂ dir
BASE=${FILENAME##*/}
The built-in ## construct will handle space and other special characters.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2004 03:40 PM
09-12-2004 03:40 PM
Re: check valid filename length of all .abc files in current⊂ dir
## Environment variable
DIR=/tmp/
echo "Enter the length of file length"
read LEGNTH
find $DIR -name "*.c" -exec basename {} \; | while read line; do
> [[ $(echo $line | awk '{ print length($1) }') -gt $LEGNTH ]] && echo "$line file is having filename length more than $LEGNTH"
> done
- Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2004 03:58 PM
09-12-2004 03:58 PM
Re: check valid filename length of all .abc files in current⊂ dir
That doesn't add much to the prior replies, and go totaly the opposite of Bill's reply.
Bill suggests that for larger tasks it helps to minimize image activations. I second that advice. Too many shell scripts just brute-force the problems damn the costs.
Muthu's script for example tosses in 4 gratuiteous, needless, images activations, with just one conditional.
You _will_ notice this if you need to find a few dozen files amongst a hundreds of thousands.
'basename': The shell knows how to get a basename (as per earlier reply)
'awk': The shell knows how to find a string length (as per earlier reply)
2*'echo': The shell knows how to 'print' if you let it.
Ok, I'll get of my high horse now, too easy to fall. It's time to go to bed over here.
Cheers,
Hein.
$ which echo
/usr/bin/echo
$ file /usr/bin/echo
/usr/bin/echo: ELF-32 executable object file - IA64
$ which print
no print in ...
$ print test
test
$ echo test
test
$