LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash Scripting, looping through subdirectories to create 1 and 0 column of values (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scripting-looping-through-subdirectories-to-create-1-and-0-column-of-values-4175422781/)

conejo_perez16 08-18-2012 11:36 AM

Bash Scripting, looping through subdirectories to create 1 and 0 column of values
 
Hello, everybody, I have several subdirectories which contains several files with .SAC extension, for example

folder01
01.SAC
02.SAC
04.SAC

Notice 03.SAC is missing.

folder 02
02.SAC
03.SAC
04.SAC

Notice 01.SAC is missing

So, what I need is.. for every missing file display a 0, otherwise display 1

For example

from folder01 I need a simple text file (lets say file01.dat)with a column with the following:

1
1
0
1

Similarly for folder02 I need (file02.dat)

0
1
1
1

And if possible merge all this, like:

finalfile.dat

1
1
0
1
0
1
1
1

Is there a way to do this????

Thanks!!

schneidz 08-18-2012 12:11 PM

where in your script are you having problems ?

conejo_perez16 08-18-2012 03:40 PM

Honestly I haven't even tried, but no good ideas come to my mind

schneidz 08-18-2012 06:33 PM

use the find command in a loop looking for 01.sac, 02.sac, 03.sac, ...
if the string that find returns is not zero length then echo '1'; else echo '0'.

man find
man test


All times are GMT -5. The time now is 11:35 AM.