Sponsored Content
Top Forums Shell Programming and Scripting how can i find number of lines in files & subdirectories Post 302474860 by Corona688 on Thursday 25th of November 2010 05:46:54 PM
Old 11-25-2010
for a file:

Code:
wc -l filename

I'm presuming by "a directory" you mean "sum of lines for all files in a directory". If you don't want to include subdirectories:

Code:
cat dir/* | wc -l

If you do:
Code:
find dir -type f | xargs cat | wc -l

This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Count number of files in subdirectories

Hello, I am new to unix and would like to have a count of all the files in the current directory as well as all the files in a subdirectory. The command I used was ls -R | wc -l but the number returned wasn't correct. Can someone please help? Thanks (2 Replies)
Discussion started by: cbeverly
2 Replies

2. UNIX for Dummies Questions & Answers

list largest files in a directory & its subdirectories

I need to find the largest files in a directory & it's subdirectories. I'm not sure what options on ls -l will work to give me this. or is there another way to do this? Thanks, igidttam (6 Replies)
Discussion started by: igidttam
6 Replies

3. Shell Programming and Scripting

Find files ignoring subdirectories

Hi guys, I am searching some files not equal to the pattern with this command find ! -name "PATTERN" -type f but my problem is the find command because he also search inside subdirectories and that's the thing i don't want that. Is there any comand to ignore the directories... (4 Replies)
Discussion started by: osramos
4 Replies

4. Shell Programming and Scripting

How to find files only inside the subdirectories only?

Hi I have a directory with two subdirectories and also have a code like below to search files modified in last 2 minutes. # ls hello080909.txt inbox outbox # find . -type f -mmin +2 ./inbox/hello2080909.txt ./outbox/hi0080909.txt ./hello080909.txt The above code just searches and... (3 Replies)
Discussion started by: Tuxidow
3 Replies

5. Shell Programming and Scripting

Find *.tar files under all subdirectories

Hi there, I'm new to shell scripting... I've a situation like to find *.tar files under all subdirectories in "/home/abcd" and i used the below, find /opt/lhapp ! -name "temp" | more the above works fine.. Now don't need search few direcotries like "/home/abcd/aaaa",... (15 Replies)
Discussion started by: skcvasanth
15 Replies

6. UNIX for Dummies Questions & Answers

Command for total number of files (and size) across subdirectories?

Hi all... I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to know is: How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for... (9 Replies)
Discussion started by: Beun
9 Replies

7. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

8. UNIX for Dummies Questions & Answers

Rename a large number of files in subdirectories

Hi, I have a large number of subdirectories (>200), and in each of these directories there is a file with a name like "opp1234.dat". I'd like to know how I could change the names of these files to say "out.dat" in all these subdirectories in one go. Thanks! (5 Replies)
Discussion started by: lost.identity
5 Replies

9. UNIX for Dummies Questions & Answers

UNIX - command to count number of files in subdirectories

I have a folder named test/ and under that I have multiple directories and in each of the directory I have multiple log files. I want to know how many files exists under each sub directory. test |--quanrantine |--logfile1 |--logfile2 |--spooling |--logfile1 ... (4 Replies)
Discussion started by: ravikirankethe
4 Replies

10. Shell Programming and Scripting

Find a word and increment the number in the word & save into new files

Hi All, I am looking for a perl/awk/sed command to auto-increment the numbers line in file, P1.tcl: run_build_model sparc_ifu_dec run_drc set_faults -model path_delay -atpg_effectiveness -fault_coverage add_delay_paths P1 set_atpg -abort_limit 1000 run_atpg -ndetects 1000 I would like... (6 Replies)
Discussion started by: jypark22
6 Replies
ttysrch(4)							   File Formats 							ttysrch(4)

NAME
ttysrch - directory search list for ttyname DESCRIPTION
ttysrch is an optional file that is used by the ttyname library routine. This file contains the names of directories in /dev that contain terminal and terminal-related device files. The purpose of this file is to improve the performance of ttyname by indicating which subdirec- tories in /dev contain terminal-related device files and should be searched first. These subdirectory names must appear on separate lines and must begin with /dev. Those path names that do not begin with /dev will be ignored and a warning will be sent to the console. Blank lines (lines containing only white space) and lines beginning with the comment character "#" will be ignored. For each file listed (except for the special entry /dev), ttyname will recursively search through subdirectories looking for a match. If /dev appears in the ttysrch file, the /dev directory itself will be searched but there will not be a recursive search through its subdirectories. When ttyname searches through the device files, it tries to find a file whose major/minor device number, file system identifier, and inode number match that of the file descriptor it was given as an argument. If a match is not found, it will settle for a match of just major/minor device and file system identifier, if one can be found. However, if the file descriptor is associated with a cloned device, this algorithm does not work efficiently because the inode number of the device file associated with a clonable device will never match the inode number of the file descriptor that was returned by the open of that clonable device. To help with these situations, entries can be put into the /etc/ttysrch file to improve performance when cloned devices are used as terminals on a system (for example, for remote login). However, this is only useful if the minor devices related to a cloned device are put into a subdirectory. (It is important to note that device files need not exist for cloned devices and if that is the case, ttyname will eventually fail.) An optional second field is used in the /etc/ttysrch file to indicate the matching criteria. This field is separated by white space (any combination of blanks or tabs). The letter M means major/minor device number, F means file system identifier, and I means inode number. If this field is not speci- fied for an entry, the default is MFI which means try to match on all three. For cloned devices the field should be MF, which indicates that it is not necessary to match on the inode number. Without the /etc/ttysrch file, ttyname will search the /dev directory by first looking in the directories /dev/term, /dev/pts, and /dev/xt. If a system has terminal devices installed in directories other than these, it may help performance if the ttysrch file is created and con- tains that list of directories. EXAMPLES
Example 1 A sample display of /etc/ttysrch command. A sample /etc/ttysrch file follows: /dev/term MFI /dev/pts MFI /dev/xt MFI /dev/slan MF This file tells ttyname that it should first search through those directories listed and that when searching through the /dev/slan direc- tory, if a file is encountered whose major/minor devices and file system identifier match that of the file descriptor argument to ttyname, this device name should be considered a match. FILES
/etc/ttysrch SEE ALSO
ttyname(3C) SunOS 5.11 23 Feb 1994 ttysrch(4)
All times are GMT -4. The time now is 02:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy