parsing 'ls' considered harmful

This commit is contained in:
Christoffer Müller Madsen 2017-10-13 18:54:32 +02:00
parent 05978c6c18
commit 0dd6939da2

View File

@ -6,7 +6,7 @@ log_dir = LOG_DIR
users.each do |user| users.each do |user|
size = `du -B1 #{shot_dir}#{user}/ | awk {'print $1'} | head -n 1` size = `du -B1 #{shot_dir}#{user}/ | awk {'print $1'} | head -n 1`
count = `ls -1 #{shot_dir}#{user}/ | wc -l | head -n 1` count = `find #{shot_dir}#{user}/ -maxdepth 1 -type f | wc -l | head -n 1`
[size,count].each do |x| [size,count].each do |x|
x.delete! "\n" x.delete! "\n"