LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   bash: sorting a bunch of files into two halfs by size, and other tasks (https://www.linuxquestions.org/questions/general-10/bash-sorting-a-bunch-of-files-into-two-halfs-by-size-and-other-tasks-614591/)

PatrickMay16 01-18-2008 03:00 PM

bash: sorting a bunch of files into two halfs by size, and other tasks
 
Hello again.

I'd like to write a script that takes a folder full of wave files, puts them into two groups of half size each (for example, there's a folder with 100MB of wave files so the script halves them into two groups of 50MB), then simultaneously runs a command on the different groups of files.

This way, I can take advantage of my dual core processor even though the current versions of oggenc and lame don't take advantage of multi-core/processor systems.

However, my bash scripting knowledge is very limited. BIG PENIS. Now's your chance! Together, we can write a script that can do this.
So basically, I'm asking for some help and advice, and information, that will help me do this.

Thanks.

Daws 01-18-2008 09:50 PM

Quote:

However, my bash scripting knowledge is very limited. BIG PENIS. Now's your chance! Together, we can write a script that can do this.
So basically, I'm asking for some help and advice, and information, that will help me do this.
ROFL.

Anyways, I'm not an expert on scripting either, I just thought I'd mention that I have had great difficulty getting bash to do things simultaneously. There is a old thread of mine around here about it, to date I still don't know how to do it. Its fairly easy to get bash to things one after the other very quickly. But when you are encoding, I imagine it may make a difference. You may have to use a proper programming language.

Good luck.

ntubski 01-19-2008 01:04 AM

How about this:
Code:

#Doesn't take size into account,
#I'm sure it's possible to do that too...
NFILES=$(ls |tee files | wc -l)
GRP1=$(head -$((NFILES/2)) files)
GRP2=$(tail -$((NFILES - NFILES/2)) files)

command $GRP1 &
command $GRP2



All times are GMT -5. The time now is 12:03 AM.