Last active
October 27, 2021 23:00
-
-
Save i3p9/6391674330a5caaca5af3b5c19690827 to your computer and use it in GitHub Desktop.
generate range and array in bash, pass it as a argument in python as list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ran=$RANDOM | |
#rng=$(( $RANDOM % 1000 )); | |
#Better method to get the range: | |
rng=$(jot -r 1 10000 10001) #One numner between 10000 and 10001 | |
LIST="" | |
for i in $(seq 1 $rng); | |
do | |
num=$(( $RANDOM % 100 )); | |
LIST+="$num" | |
LIST+="*" | |
#echo $num >> list.txt # That's how you'll put the cpu values inside txt | |
## Variable >> text.txt appends the values, one > Replaces previous values | |
done | |
LIST=$(sed 's/*/ /g' <<< $LIST) | |
# start cpu measurement | |
EXTIME=$(time python3 up.py -l $LIST) | |
#stop cpu measurement | |
echo $EXTIME >> list.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
parser = argparse.ArgumentParser(description='Process a big list') | |
parser.add_argument('-l','--list', nargs='+', help='<Required> Set flag', required=True) | |
args = parser.parse_args() | |
#print(args.list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to run the script
foo.sh
chmod +x foo.sh
./foo.sh