Skip to content

Instantly share code, notes, and snippets.

@i3p9
Last active October 27, 2021 23:00
Show Gist options
  • Save i3p9/6391674330a5caaca5af3b5c19690827 to your computer and use it in GitHub Desktop.
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
#!/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
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)
@i3p9
Copy link
Author

i3p9 commented Oct 27, 2021

How to run the script foo.sh

  • Give it permission to execute chmod +x foo.sh
  • Execute ./foo.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment