how to find the number of files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to find the number of files
# 1  
Old 10-05-2007
how to find the number of files

hi,

1) I want to find from the current directory the number of files (count) with two or more particular extentions in another directory.

For ex: If I am in a/b/c directory... I want to find the count of the files with .txt and .dat extention in a/d/e directory. I have tried using the below one:

a/b/c> ls a/d/e/*.txt *.dat | wc -l --- this is not working.. Please help.

2) In the above directory a/d/e, i want to get the name of the last file with extention *.dat-- how to get it

Thanks in advance,
Harish
# 2  
Old 10-05-2007
Try this

ls | wc -l
# 3  
Old 10-05-2007
do this

Harish,

do this.this shud work


find a/d/e/ -type f \( -name "*.txt" -o -name "*.dat" \) | xargs ls -l | wc -l


all the best.


cheers,
Devaraj Takhellambam
# 4  
Old 10-06-2007
Quote:
a/b/c> ls a/d/e/*.txt *.dat | wc -l
this would display *.txt files from a/d/e and *.dat files from a/b/c

try this

Code:
ls a/d/e/*.txt a/d/e/*.dat

# 5  
Old 10-08-2007
Quote:
Originally Posted by devtakh
Harish,

do this.this shud work


find a/d/e/ -type f \( -name "*.txt" -o -name "*.dat" \) | xargs ls -l | wc -l


all the best.


cheers,
Devaraj Takhellambam
Thanks man... its working.. can you answer the 2nd query tooo ...
# 6  
Old 10-09-2007
Code:
ls -lrt a/d/e/*.dat | awk 'END{print}'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to count number of files in directory and write to new file with number of files and their name?

Hi! I just want to count number of files in a directory, and write to new text file, with number of files and their name output should look like this,, assume that below one is a new file created by script Number of files in directory = 25 1. a.txt 2. abc.txt 3. asd.dat... (20 Replies)
Discussion started by: Akshay Hegde
20 Replies

2. Shell Programming and Scripting

Bash script to find the number of files and identify which ones are 0 bytes.

I am writing a bash script to find out all the files in a directory which are empty. I am running into multiple issues. I will really appreciate if someone can please help me. #!/bin/bash DATE=$(date +%m%d%y) TIME=$(date +%H%M) DIR="/home/statsetl/input/civil/test" ... (1 Reply)
Discussion started by: monasharma13
1 Replies

3. Shell Programming and Scripting

Using find in a directory containing large number of files

Hi All, I have searched this forum for related posts but could not find one that fits mine. I have a shell script which removes all the XML tags including the text inside the tags from some 4 million XML files. The shell script looks like this (MODIFIED): find . "*.xml" -print | while read... (6 Replies)
Discussion started by: shoaibjameel123
6 Replies

4. Shell Programming and Scripting

Find the number of files older than 1 day from a dir

Hello All, I need to write a script/command which can find out the number of .csv files residing in a directory older than 1 day. The output should come with datewise (means for each date how many files are there). I've this command, but this command gives the total number of files. It's... (10 Replies)
Discussion started by: NARESH1302
10 Replies

5. Shell Programming and Scripting

how can i find number of lines in files & subdirectories

how can i find number of lines in files & subdirectories ? (3 Replies)
Discussion started by: pcbuilder
3 Replies

6. Shell Programming and Scripting

Find the user with less number of files in the system

Good morning everybody, I'm using Minix and I want to find the user with less number of files in the system I have tried this solution: #! /bin/sh indice=0 listaCut=$(cut -f 3 -d : /etc/passwd) for USER in $listaCut; do cont=0 listaFind=$(find / -user "${USER}" -type -f) ... (4 Replies)
Discussion started by: Guccio
4 Replies

7. UNIX for Dummies Questions & Answers

Problem using find with prune on large number of files

Hi all; I'm having a problem when want to list a large number of files in current directory using find together with the prune option. First i used this command but it list all the files including those in sub directories: find . -name "*.dat" | xargs ls -ltr Then i modified the command... (2 Replies)
Discussion started by: ashikin_8119
2 Replies

8. Shell Programming and Scripting

How to do a find number of files in awk

Hi, How can i able to do a similar operation to "find" number of files in a folder in an awk? In bash, we could do easily using "find" command. But currently, I am having an awk block and i wanted to extract these information. Please advise. Thanks. (2 Replies)
Discussion started by: ahjiefreak
2 Replies

9. Shell Programming and Scripting

script to find the average number or files?

Anyone has a script or command in UNIX that can take 4 to five different numbers and calculate the average? (2 Replies)
Discussion started by: bbbngowc
2 Replies

10. Shell Programming and Scripting

awk script to find the number of files

awk script to find the number of files in a directory with their date less than 15-oct-2006 please help (4 Replies)
Discussion started by: uni_ajay_r
4 Replies
Login or Register to Ask a Question