Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to Get the count fo files in each subfolder Post 302359231 by Scott on Tuesday 6th of October 2009 05:30:39 AM
Old 10-06-2009
Hi.

I suppose one simple way would be:

bash code:
  1. find . -type d | while read DIR; do
  2.   ls $DIR | echo $DIR $(wc -w)
  3.  
  4. ... or echo $DIR $(ls $DIR | wc -w) ... if you prefer!
  5. done
 

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Samba read only subfolder.

Hi, I need to make a folder read only under a fileshare that has full permissions granted to it. The fileshare with full permissions is /u02/prodfileshare. The folder I need to make read only for everyone except the owner of the folder is called /u02/prodfileshare/EFT/purchases. ... (0 Replies)
Discussion started by: sparcman
0 Replies

2. UNIX for Dummies Questions & Answers

Unzip subfolder to some path.

I have a zip file (somezipfile.zip) with the following contents in it: dir1/subdir1/somefile1.txt dir1/subdir2/somefile2.txt dir1/subdir2/somefile3.txt dir1/somefile3.txt dir1/somefile4.txt dir2/somefile5.txt dir2/somefile6.txt Lets say I unzip this to my home directory so now I have: ... (0 Replies)
Discussion started by: mrwatkin
0 Replies

3. Shell Programming and Scripting

Link multiple files from different subfolder to a new subfolder

Hi, I have the following subfolder with files: /data/a/1/xxx.txt /data/b/2/yyy.txt /data/c/3/zzz.txt And i have a set of new folders which have exactly the same structure as above but different disk without the files: /data_02/a/1/ /data_02/b/2/ /data_02/c/3/ Now i would like to... (6 Replies)
Discussion started by: total_ysf
6 Replies

4. UNIX for Dummies Questions & Answers

removing files in a given subfolder

Hello, im new to this forum and directly start with a problem... :) I have a folder structure like : /folder/01/1/oldfiles /folder/01/2/oldfiles /folder/02/1/oldfiles /folder/0x/y/oldfiles Every Month a new folder adds automaticly from the system. Now i need an idea how to search... (6 Replies)
Discussion started by: Hugi
6 Replies

5. Shell Programming and Scripting

List of files in a folder inclusive subfolder

Hi, I need to list the names of existing files in a specific folder. I have written a script for that, but the problem is, it is also picking up name of a subfolder that is there in that folder. I need only the list of files and not that subfolder. How to go about that ? Can anyone plz help... (2 Replies)
Discussion started by: Subhasis
2 Replies

6. Shell Programming and Scripting

Error files count while coping files from source to destination locaton as well count success full

hi All, Any one answer my requirement. I have source location src_dir="/home/oracle/arun/IRMS-CM" My Target location dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct" my source text files check with below example.text file content $fn "\t" $dc "\t" $pc "\t" ... (3 Replies)
Discussion started by: sravanreddy
3 Replies

7. Shell Programming and Scripting

Shell script for field wise record count for different Files .csv files

Hi, Very good wishes to all! Please help to provide the shell script for generating the record counts in filed wise from the .csv file My question: Source file: Field1 Field2 Field3 abc 12f sLm 1234 hjd 12d Hyd 34 Chn My target file should generate the .csv file with the... (14 Replies)
Discussion started by: Kirands
14 Replies

8. Shell Programming and Scripting

Bash - Find files excluding file patterns and subfolder patterns

Hello. For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Discussion started by: jcdole
2 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. Shell Programming and Scripting

Bash to copy subfolder and files to matching directory

The bash executes but returns no results and the set -xv showed while the $run variable in blue, was extracted correctly, the $match value in green, was not, rather both values in home/cmccabe/Desktop/f1 were extracted not just the matching. There will always be an exact match from the $run to... (7 Replies)
Discussion started by: cmccabe
7 Replies
DIR(3)									 1								    DIR(3)

dir - Return an instance of the Directory class

SYNOPSIS
Directory dir (string $directory, [resource $context]) DESCRIPTION
A pseudo-object oriented mechanism for reading a directory. The given $directory is opened. PARAMETERS
o $directory - Directory to open o $context - Note Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams". RETURN VALUES
Returns an instance of Directory, or NULL with wrong parameters, or FALSE in case of another error. EXAMPLES
Example #1 dir(3) example Please note the fashion in which Directory.read(3)'s return value is checked in the example below. We are explicitly testing whether the return value is identical to (equal to and of the same type as - see Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop. <?php $d = dir("/etc/php5"); echo "Handle: " . $d->handle . " "; echo "Path: " . $d->path . " "; while (false !== ($entry = $d->read())) { echo $entry." "; } $d->close(); ?> The above example will output something similar to: Handle: Resource id #2 Path: /etc/php5 apache cgi cli NOTES
Note The order in which directory entries are returned by the read method is system-dependent. PHP Documentation Group DIR(3)
All times are GMT -4. The time now is 06:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy