Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-27-2009, 01:43 PM   #1
LQ Newbie
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
working with grip

how would i modify this function to descend all subdirectories of the named directory recursively and to find the maximum length of any filename in that hierarchy.

$ function maxfn () {
> typeset -i max thisone
> if [ ! -d "$1" -o $# = 0 ]
> then
> echo "Usage: maxfn dirname"
> return 1
> fi
> max=0
> for fn in $(/bin/ls $1)
> do
> thisone=${#fn}
> if [ $thisone -gt $max ]
> then
> max=$thisone
> fi
> done
> echo "Longest filename is $max characters."
> }
Old 06-27-2009, 02:37 PM   #2
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 70
Sometime ago I wrote a simple script to run over a directory tree recursively.
Here it is. I think you can adapt it to your problem easily.


    for file in *
    do if [ -d $file ] 
            then echo "Descending into $file" 
            cd $file
            cd ..


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working Grip 3.3.1 settings in Ubuntu 7.10 for FLAC with working meta info robocoop Linux - Software 0 04-06-2008 04:28 PM
my grip...what do you think is best :) Mohtek General 11 10-01-2007 11:28 AM
Grip not working (Doesn't load) Rundi Linux - Software 3 03-20-2004 11:10 AM
Grip... Linux~Powered Linux - Software 4 03-08-2004 09:28 PM
Grip id3 tagging not working (or so it seems?) MasterC Linux - Software 1 02-27-2003 01:33 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration