Skip to content

Instantly share code, notes, and snippets.

@BenSYZ
Last active November 15, 2021 11:19
Show Gist options
  • Save BenSYZ/c21b7e44f6c6d4a32bb839fc34a793ae to your computer and use it in GitHub Desktop.
Save BenSYZ/c21b7e44f6c6d4a32bb839fc34a793ae to your computer and use it in GitHub Desktop.
#!/bin/zsh
cat $1 |\
jq '.cells|.[] |select(.cell_type == "code") | .source|.[]' |\
sed -n 's/"\(.*\)\\n"/\1/p' |\
sed 's/\\"/"/g' > $1.py
# jq select code cell
# sed 1. remove the prefix " and suffix \n"
# 2. " in code will save as \"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment