[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Gods of Linux, how is it that there are only 80,000 songs in

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 1

File: Screenshot_23.png (2KB, 305x132px) Image search: [Google]
Screenshot_23.png
2KB, 305x132px
Gods of Linux, how is it that there are only 80,000 songs in this folder, but find is returning 199,418?

>for i in {0..50}; do find ~/songs/ -iname "*.mp3" -o -iname "*.ogg" -typ
e f -mtime $i | wc -l; done | awk '{ sum += $1 } END { print sum }'
>199418

0..50 is just for exaggeration that I've fucked up somewhere.
>>
>>215256
I'm from the other thread.

Two things:

You are successively looking at older and older files with the 1..50. The next iteration of mtime 37 will already include the files from mtime 36, so you're inflating the number of found files.

The other problem is a common gotcha: I'm sure you meant to say

find ~/songs \( -iname '*mp3' -o -iname '*ogg' \) -type f ...

Note the gratuitous space around the escaped parantheses. Try your commands on a very simplified example, without the for i 1..50 and you'll see that you get different results on your version if you interchange -iname '*mp3' -o -iname '*ogg', or if you check for ogg first and then the mp3.
>>
>>215267
What I mean to say is:

find THIS -o THAT -type f -THENDOTHIS

will only result in a THENDOTHIS if the THAT matches. There is no trigger on the THENDOTHIS if the THIS matches. You need the parantheses for the two conditional expressions
>>
>>215256One last thing.

Why not

find ~/songs/ -type f -ls | egrep -i ".(mp3|ogg)" | wc -l
>>
>>215267
>>215268
jessie@debian:~$ find ~/songs \( -iname '*.mp3' -o -iname '*.ogg' \) -type f -mtime 0 | wc -l
817

jessia@debian:~$ find ~/songs/ -iname '*.mp3' -o -iname '*.ogg' -type f -mtime 0 | wc -l
3937

Seems to be working.
>>
>>215271
Now switch it to ogg first and then mp3 and try it again ...
>>
>>215270
jessie@debian:~$ time find ~/songs \( -iname '*.mp3' -o -iname '*.ogg' \) -type f -mtime 0 | wc -l
814

real 0m0.230s
user 0m0.136s
sys 0m0.092s
jessie@debian:~$ time find ~/songs/ -type f -mtime 0 -ls | egrep -i ".(mp3|ogg)" | wc -l
814

real 0m0.151s
user 0m0.044s
sys 0m0.116s


Using ls and egrep is faster. Who'd have thought grep could make it faster?
>>
>>215272
Same output. Thanks it was bugging me for a while.
>>
>>215277
>jessie@debian:~$ time find ~/songs/ -type f -mtime 0 -ls | egrep -i ".(mp3|ogg)" | wc -l
>814
>real 0m0.151s
>user 0m0.044s
>sys 0m0.116s
>jessie@debian:~$ time find ~/songs \( -iname '*.mp3' -o -iname '*.ogg' \) -type f -mtime 0 > 'my list of .mp3 and .ogg files.txt'
>jessie@debian:~$ time find ~/songs/ -type f -mtime 0 -ls | egrep -i ".(mp3|ogg)" | wc -l
>815
>real 0m0.151s
>user 0m0.044s
>sys 0m0.116s
>>
>>215280
What?
>>
>>215280
>>215283
Never mind I see the increased value of results due to the output going to 'my list of .mp3 and .ogg files.txt'. Fixed by appending $ to signify end of line
>find ~/songs/ -type f -mtime 0 -ls | egrep -i ".(mp3$|ogg$)" | wc -l
Thread posts: 11
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.