Created
August 6, 2019 15:19
-
-
Save ivyleavedtoadflax/0993058ed2b25d93042219da602706bd to your computer and use it in GitHub Desktop.
Iterate through a bash file and do some things
This file contains 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
for i in raw/*.json; | |
do | |
# Create new filename | |
filename=$(basename -- "$i") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
new_filename=processed/refs_${filename}.txt | |
# Shuffle the first 1000 rows, and extract the reference sections | |
# then save as a new file. | |
cat $i | shuf | head -n 1000 | jq .sections.Reference > ${new_filename} | |
# Remove all the null values created by jq | |
sed /^null$/d -i ${new_filename} | |
echo "Output ${new_filename}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment