linux awk中输出1~100的所有质数

 

1、

root@PC1:/home/test2# for num in `seq 2 100`;do if [ `factor $num|awk '{print $2}'` == $num ];then echo -n "$num ";fi done;echo
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

 

来源:https://mp.weixin.qq.com/s?__biz=MzU5NDg5MzM5NQ==&mid=2247495592&idx=1&sn=0780cc96bc18bf3ba5b1b50e243a8e9a&chksm=fe78e094c90f698244a1acb0b33ab4cb9ab215dd86d4e227c6a12b2387de2f42ebadd024e517&mpshare=1&scene=23&srcid=0501IxzLQzAVxjYg4OhuPhnU&sharer_sharetime=1651338673976&sharer_shareid=50b75c6a886e09824b582fb782a7678b#rd

posted @ 2022-05-01 12:25  小鲨鱼2018  阅读(238)  评论(0编辑  收藏  举报