Sponsored Content
Top Forums Shell Programming and Scripting List directories and count files inside Post 302877876 by scribling on Tuesday 3rd of December 2013 04:35:01 PM
Old 12-03-2013
That almost worked. I altered it slightly and now it works great.

Code:
find . -depth -type l -print | while read path
do
    path=${path#./}
    if [ ${#path} -ge ${prev:-0} ]
    then
        prev=${#path}
        indent=""
        IFS='/'
        set -- $path
        IFS=$' \t\n'
        while [ $# -gt 0 ]
        do
           echo "$indent$1"
           indent="   $indent"
           shift
        done
        echo "$indent$(ls $path | head -1)"
        echo "$indent$(ls $path | tail -1)"
    fi
done

Thank you very much!

---------- Post updated at 01:35 PM ---------- Previous update was at 01:16 PM ----------

I spoke too soon. That script works if there are no sub directories.
Without sub directories result:
Code:
DPX
   pe0880_v400002
      pe0880_v400002.1000.dpx
      pe0880_v400002.1041.dpx
DPX
   pe0880_v400003
      pe0880_v400003.1000.dpx
      pe0880_v400003.1041.dpx
DPX
   pg1100_v400019
      pg1100_v400019.1000.dpx
      pg1100_v400019.1120.dpx
QT
   pe0880_v400002.mov
      QT/pe0880_v400002.mov
      QT/pe0880_v400002.mov
QT
   pe0880_v400003.mov
      QT/pe0880_v400003.mov
      QT/pe0880_v400003.mov
QT
   pg1100_v400019.mov
      QT/pg1100_v400019.mov
      QT/pg1100_v400019.mov


With subdirectories the result:
Code:
DPX
   pe0880_v400002
      2404x912
      2404x912
DPX
   pe0880_v400003
      2404x912
      2404x912
DPX
   pg1100_v400019
      2404x912
      2404x912
QT
   pe0880_v400002.mov
      QT/pe0880_v400002.mov
      QT/pe0880_v400002.mov
QT
   pe0880_v400003.mov
      QT/pe0880_v400003.mov
      QT/pe0880_v400003.mov
QT
   pg1100_v400019.mov
      QT/pg1100_v400019.mov
      QT/pg1100_v400019.mov

Ideally, only the .dpx files would show first and last. Any other file type would simply be listed.
Like this:
Code:
DPX
   pe0880_v400002
      2404x912
         pe0880_v400002.1000.dpx
         pe0880_v400002.1041.dpx

   pe0880_v400003
      2404x912
         pe0880_v400003.1000.dpx
         pe0880_v400003.1041.dpx

   pg1100_v400019
      2404x912
         pg1100_v400019.1000.dpx
         pg1100_v400019.1120.dpx
QT
   pe0880_v400002.mov
   pe0880_v400003.mov  
   pg1100_v400019.mov

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need script to find errored files inside directories

Hi people. I working on a script to check for files that they are suposed not to be on the directory. I mean, inside of each directory it must have some files but some could be wrong, and i want to move the files that are wrong. Ex: CSPOTGET edpst/CargadoresSPOT Historicos_Spot_MDI.zip... (4 Replies)
Discussion started by: osramos
4 Replies

2. Solaris

Get Count of all files in all the directories

Hello, I am looking for a way to get the TOTAL COUNT of the files present in all directories(sub directories) under the root directory..The files can be of any type viz. txt, doc, html, wav, jpeg etc. If it has an extension, it has to be counted.. I want to run the script from the root directory.... (6 Replies)
Discussion started by: oniondosa
6 Replies

3. Shell Programming and Scripting

AWK Script - Count Files In Directories

Hey, I'm very new to AWK and am trying to write a script that counts the number of files in all subdirectories. So, basically, my root has many subdirectories, and each subdirectory has many files. How can I get the total count? I haven't been able to figure out how to loop through the... (1 Reply)
Discussion started by: beefeater267
1 Replies

4. Shell Programming and Scripting

Count of files in directories

Hi, I have a requirement to find out the count of files in directories. I can do this very well by goind to each directory and then ls -lrt | wc -l. But I need to do it for hundreds of directories/sub-directories. I tried with this - for i in `ls -F | grep '/$'`; do `echo "$i"`| ls -lrt... (2 Replies)
Discussion started by: unx100
2 Replies

5. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

6. UNIX for Dummies Questions & Answers

Count of files and directories

Hi I have a jfs2 filesystem named /software in my aix 5.3 box. Please note that there are a lot of subdirectories under /software? I need to know the count of how many total files and directories are present under that mount point /software ? For example if by some commands we find that there... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

7. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

8. Shell Programming and Scripting

Script to count number of files in directories

Hi All! I would like to have a script that will count the number of files at the top of the hour of soome directories and mail the results to me. I was thinking on : a=`/directory/subdirectory/ | wc -l` echo "/directory/subdirectory :$a" b=`/another_dir/subdir/ | wc -l` echo... (12 Replies)
Discussion started by: fretagi
12 Replies

9. Shell Programming and Scripting

Count files between multiple directories

Hi All, Everyday we will receive 33 files in our source directory(/prd/pk) with the current date. Once our jobs are completed all the 33 files immediately will be moved to backup folder (/prd/pk/backup). Now, I need to check between source file directory (/prd/pdk) and backup file directory... (3 Replies)
Discussion started by: suresh_target
3 Replies

10. Shell Programming and Scripting

How to delete all the files and folders inside all the directories except some specific directory?

hi, i have a requirement to delete all the files from all the directories except some specific directories like archive and log. for example: there are following directories such as A B C D Archive E Log F which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
Discussion started by: Little
7 Replies
DH_INSTALLDEB(1)						     Debhelper							  DH_INSTALLDEB(1)

NAME
dh_installdeb - install files into the DEBIAN directory SYNOPSIS
dh_installdeb [debhelperoptions] DESCRIPTION
dh_installdeb is a debhelper program that is responsible for installing files into the DEBIAN directories in package build directories with the correct permissions. FILES
package.postinst package.preinst package.postrm package.prerm These maintainer scripts are installed into the DEBIAN directory. Inside the scripts, the token #DEBHELPER# is replaced with shell script snippets generated by other debhelper commands. package.triggers package.shlibs These control files are installed into the DEBIAN directory. package.conffiles This control file will be installed into the DEBIAN directory. In v3 compatibility mode and higher, all files in the etc/ directory in a package will automatically be flagged as conffiles by this program, so there is no need to list them manually here. package.maintscript Lines in this file correspond to dpkg-maintscript-helper(1) commands and parameters. Any shell metacharacters will be escaped, so arbitrary shell code cannot be inserted here. For example, a line such as "mv_conffile /etc/oldconffile /etc/newconffile" will insert maintainer script snippets into all maintainer scripts sufficient to move that conffile. A versioned Pre-Dependency on dpkg is needed to use dpkg-maintscript-helper(1). An appropriate Pre-Dependency is set in ${misc:Pre-Depends} ; you should make sure to put that token into an appropriate place in your debian/control file. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 9.20120909 2011-09-12 DH_INSTALLDEB(1)
All times are GMT -4. The time now is 06:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy