OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: Jon_J on February 09, 2007, 05:56:09 pm

Title: List Number Of Files In A Directory?
Post by: Jon_J on February 09, 2007, 05:56:09 pm
I'm copying some data files for a game to a directory on my /hdc1
There are supposed to be 158 files in this directory. I accidentally left 4 files out, but when comparing them on windows, I had one too many files after copying the 4 files.
So I found the file and removed it.
When I tried to look at this directory on my Zaurus, I couldn't find the command switch for ls to list the number of files in this directory.
I used emelFM, but it didn't have the option to show the number of files in a directory, so I hi-lited all the files and clicked the "File info" button. That didn't work either.
Needless to say, after clicking that "File info" button, I had to manually close 158 dialog boxes...whew!  
After I closed emelFM, I restarted X, just in case I buggered something up.
In Linux, how do you do a file count inside a directory?
I don't want to install another filemanager at this point.
Isn't there a console command that does this? like "dir" in DOS
Thank you

Jon
Title: List Number Of Files In A Directory?
Post by: Meanie on February 09, 2007, 06:02:34 pm
Quote
I'm copying some data files for a game to a directory on my /hdc1
There are supposed to be 158 files in this directory. I accidentally left 4 files out, but when comparing them on windows, I had one too many files after copying the 4 files.
So I found the file and removed it.
When I tried to look at this directory on my Zaurus, I couldn't find the command switch for ls to list the number of files in this directory.
I used emelFM, but it didn't have the option to show the number of files in a directory, so I hi-lited all the files and clicked the "File info" button. That didn't work either.
Needless to say, after clicking that "File info" button, I had to manually close 158 dialog boxes...whew!   
After I closed emelFM, I restarted X, just in case I buggered something up.
In Linux, how do you do a file count inside a directory?
I don't want to install another filemanager at this point.
Isn't there a console command that does this? like "dir" in DOS
Thank you

Jon
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153663\"][{POST_SNAPBACK}][/a][/div]

ls /somedir/ |wc -l
Title: List Number Of Files In A Directory?
Post by: Jon_J on February 09, 2007, 06:06:41 pm
That worked. I was already in the directory, so I did ls |wc -l (I put this shortcut on a button in emelFM)

That's not shown in ls --help ( this is a copy/paste from ls --help in Cacko)
Code: [Select]
BusyBox v0.60.4 (2003.04.15-01:23+0000) multi-call binary

Usage: ls [-1AacCdeFilnpLRrSsTtuvwxXhk] [filenames...]

List directory contents

Options:
        -1      list files in a single column
        -A      do not list implied . and ..
        -a      do not hide entries starting with .
        -C      list entries by columns
        -c      with -l: show ctime
        -d      list directory entries instead of contents
        -e      list both full date and full time
        -F      append indicator (one of */=@|) to entries
        -i      list the i-node for each file
        -l      use a long listing format
        -n      list numeric UIDs and GIDs instead of names
        -p      append indicator (one of /=@|) to entries
        -L      list entries pointed to by symbolic links
        -R      list subdirectories recursively
        -r      sort the listing in reverse order
        -S      sort the listing by file size
        -s      list the size of each file, in blocks
        -T NUM  assume Tabstop every NUM columns
        -t      with -l: show modification time
        -u      with -l: show access time
        -v      sort the listing by version
        -w NUM  assume the terminal is NUM columns wide
        -x      list entries by lines instead of by columns
        -X      sort the listing by extension
        -h      print sizes in human readable format (e.g., 1K 243M 2G )
        -k      print sizes in kilobytes(default)
Title: List Number Of Files In A Directory?
Post by: Meanie on February 09, 2007, 06:11:16 pm
Quote
That worked. I was already in the directory, so I did ls |wc -l

That's not shown in ls --help ( this is a copy/paste from ls --help in Cacko)
Code: [Select]
BusyBox v0.60.4 (2003.04.15-01:23+0000) multi-call binary

Usage: ls [-1AacCdeFilnpLRrSsTtuvwxXhk] [filenames...]

List directory contents

Options:
        -1      list files in a single column
        -A      do not list implied . and ..
        -a      do not hide entries starting with .
        -C      list entries by columns
        -c      with -l: show ctime
        -d      list directory entries instead of contents
        -e      list both full date and full time
        -F      append indicator (one of */=@|) to entries
        -i      list the i-node for each file
        -l      use a long listing format
        -n      list numeric UIDs and GIDs instead of names
        -p      append indicator (one of /=@|) to entries
        -L      list entries pointed to by symbolic links
        -R      list subdirectories recursively
        -r      sort the listing in reverse order
        -S      sort the listing by file size
        -s      list the size of each file, in blocks
        -T NUM  assume Tabstop every NUM columns
        -t      with -l: show modification time
        -u      with -l: show access time
        -v      sort the listing by version
        -w NUM  assume the terminal is NUM columns wide
        -x      list entries by lines instead of by columns
        -X      sort the listing by extension
        -h      print sizes in human readable format (e.g., 1K 243M 2G )
        -k      print sizes in kilobytes(default)
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153665\"][{POST_SNAPBACK}][/a][/div]

cause there is no ls option to do summaries, especially busybox ls. the command here is:  wc
Title: List Number Of Files In A Directory?
Post by: Jon_J on February 09, 2007, 06:22:44 pm
Thank you again, it will take me awhile to learn the quirks of Linux. Things have just been so easy in windows for so many years.
BTW, I was able to make that command into a button in emelFM
Title: List Number Of Files In A Directory?
Post by: Antikx on February 10, 2007, 03:17:50 am
Quote
Thank you again, it will take me awhile to learn the quirks of Linux. Things have just been so easy in windows for so many years.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153667\"][{POST_SNAPBACK}][/a][/div]
I find that is the most frustrating AND fun part of Linux. The learning curve is long but it's a heck of a ride. P
Title: List Number Of Files In A Directory?
Post by: speculatrix on February 10, 2007, 03:29:42 pm
to count all files in a multi-dir hierarchy:
find . -type f -ls | wc -l

to count dirs
find . -type d -ls | wc -l

to "reset" protection on files and dirs:
find . -type f -exec chmod u=rw,o=r,g=r {} \;
find . -type d -exec chmod u=rwx,o=rx,g=rx {} \;


find-exec is your friend, but a powerful & dangerous one :-)