█▀▀ █▄█ █▀▀ █░░ █▀▀ ░ █▀ █░█
█▄▄ ░█░ █▄▄ █▄▄ ██▄ ▄ ▄█ █▀█
v 0.0.1
Cycle.sh is a small bash script to auto-run the custom commands with looping in folders in linux-like system.
git clone
./Cycle/3rd_partylib/./install_3rd.sh
using vim open ~/.bashrc
sudo vim ~/.bashrc
edit .bashrc , add the path :
PATH=~/Cycle/:$PATH
source ~/.bashrc
./cycle.sh
-i input root path
-o output root path
-p output postfix ,defult is 'result'
-a input folder prefix
-b input folder postfix for input
(search folder pattern as a*b , defult is all)
-n not creat output sub folder , defult will creat by mkdir command
use
please use those two var :
$input_sub_dir , the root of input folder for each loop
$output_each_dir, the output folder for each loop
to define the commands your own , for example:
custom_cmd.sh:
cmd='ls $input_sub_dir > $output_each_dir/data.txt &'
echo "run cmd : "$cmd
eval $cmd
and run :
./cycle.sh -i ./test -o ./out -c custom_cmd.sh
the outputs will be like:
current procressing input dir : ./test/1
current output dir : ./out/1_result
run cmd : ls $input_sub_dir > $output_each_dir/data.txt &
-----------------------
current procressing input dir : ./test/2
current output dir : ./out/2_result
run cmd : ls $input_sub_dir > $output_each_dir/data.txt &
-----------------------
current procressing input dir : ./test/3
current output dir : ./out/3_result
run cmd : ls $input_sub_dir > $output_each_dir/data.txt &
-----------------------
The input path structure:
Cycle/test
├── 1
│ └── 1.txt
├── 2
│ └── 2.txt
└── 3
└── 3.txt
3 directories, 3 files
The output path structure:
/Cycle/out
├── 1_result
│ └── data.txt
├── 2_result
│ └── data.txt
└── 3_result
└── data.txt
3 directories, 3 files
./test_2/./load_data.s
fastqc -t 16 -o $output_each_dir $input_sub_dir/fastq
./cycle.sh -i ./test_2 -o ./out_2 -c custom_cmd2.sh -p fastqc -a SRR
result will be
├── SRR650259_fastqc
│ ├── fastq_fastqc.html
│ └── fastq_fastqc.zip
├── SRR650290_fastqc
│ ├── fastq_fastqc.html
│ └── fastq_fastqc.zip
├── SRR651263_fastqc
│ ├── fastq_fastqc.html
│ └── fastq_fastqc.zip
├── SRR651328_fastqc
│ ├── fastq_fastqc.html
│ └── fastq_fastqc.zip
└── SRR651357_fastqc
├── fastq_fastqc.html
└── fastq_fastqc.zip