LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-27-2009, 12:43 PM   #1
Jason40k
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, 01:37 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
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.

Code:
#!/bin/bash

recursewalk(){
    for file in *
    do if [ -d $file ] 
            then echo "Descending into $file" 
            cd $file
            recursewalk
            cd ..
        fi
    done
}
recursewalk
 
  


Reply



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 03:28 PM
my grip...what do you think is best :) Mohtek General 11 10-01-2007 10:28 AM
Grip not working (Doesn't load) Rundi Linux - Software 3 03-20-2004 10:10 AM
Grip... Linux~Powered Linux - Software 4 03-08-2004 08:28 PM
Grip id3 tagging not working (or so it seems?) MasterC Linux - Software 1 02-27-2003 12:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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