Skip to content

Instantly share code, notes, and snippets.

@tobias-khs
Created February 24, 2017 06:30
Show Gist options
  • Select an option

  • Save tobias-khs/49bf1b1580b4345106cc849682e71150 to your computer and use it in GitHub Desktop.

Select an option

Save tobias-khs/49bf1b1580b4345106cc849682e71150 to your computer and use it in GitHub Desktop.
Prime number generator with Bash
#!/bin/bash
print_if_same () { while read -r -a arr; do if [ "${arr[0]}" == "${arr[1]}" ]; then echo "${arr[0]}"; fi; done ; }
yes | awk '{print NR}' | factor | IFS=': ' print_if_same
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment