need bash command help
Hello everyone. I am new to bash shell scripting and I have this problem I need to solve
Basically I have around 50,000 or so files in a directory of the format <department id>-<date>-<time>-<file id>.<ext> I need to write a command that will output a list of department ID's and their counts as well as a count of files without department ID's. I am stuck how to make this as a one command that won't break. Any help is greatly appreciated |
With that many files using flags with ls becomes a problem.
However you can usually use ls itself. Counts can be gotten with the wc command. "wc -l" shows number of lines. (Type "man wc" for more details of the command.) Count of files irrespective of department ID is simple: Code:
ls |wc -l Code:
for DEPID in $(ls -R |awk -F\- '{print $1}' |sort -u) Code:
#!/bin/bash |
Quote:
|
Glad I could help. Please go to thread tools and mark this as Solved as it helps others find solutions more quickly when doing web searches in future.
|
All times are GMT -5. The time now is 07:21 AM. |