Skip to content

Instantly share code, notes, and snippets.

@greymd
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greymd/c586bbbcfd4904178257 to your computer and use it in GitHub Desktop.
Save greymd/c586bbbcfd4904178257 to your computer and use it in GitHub Desktop.
日〜月曜日まで、ピッタリとカレンダーに収まる年を求める。
# GNU版grepを利用
echo 2" "{1..2015}$'\n' | awk NF | while read m y; do echo -n "$y年"; cal $m $y | awk NF | sed -n -e '3,3p' -e '$,$p' | tr -d '\n' | awk '$0=":"NF' ;done | grep -oP ".+(?=:13)"
#ピッタリと収まる例
# $ cal 2 2015
# February 2015
# Su Mo Tu We Th Fr Sa
# 1 2 3 4 5 6 7
# 8 9 10 11 12 13 14
# 15 16 17 18 19 20 21
# 22 23 24 25 26 27 28
# 収まらない例
# $ cal 2 2014
# February 2014
# Su Mo Tu We Th Fr Sa
# 1
# 2 3 4 5 6 7 8
# 9 10 11 12 13 14 15
# 16 17 18 19 20 21 22
# 23 24 25 26 27 28
@greymd
Copy link
Author

greymd commented Feb 1, 2015

結果 1〜2015年の間で217件検出

5年
11年
22年
33年
39年
50年
61年
67年
78年
89年
95年
106年
117年
123年
134年
145年
151年
162年
173年
179年
190年
201年
207年
218年
229年
235年
246年
257年
263年
274年
285年
291年
302年
313年
319年
330年
341年
347年
358年
369年
375年
386年
397年
403年
414年
425年
431年
442年
453年
459年
470年
481年
487年
498年
509年
515年
526年
537年
543年
554年
565年
571年
582年
593年
599年
610年
621年
627年
638年
649年
655年
666年
677年
683年
694年
705年
711年
722年
733年
739年
750年
761年
767年
778年
789年
795年
806年
817年
823年
834年
845年
851年
862年
873年
879年
890年
901年
907年
918年
929年
935年
946年
957年
963年
974年
985年
991年
1002年
1013年
1019年
1030年
1041年
1047年
1058年
1069年
1075年
1086年
1097年
1103年
1114年
1125年
1131年
1142年
1153年
1159年
1170年
1181年
1187年
1198年
1209年
1215年
1226年
1237年
1243年
1254年
1265年
1271年
1282年
1293年
1299年
1310年
1321年
1327年
1338年
1349年
1355年
1366年
1377年
1383年
1394年
1405年
1411年
1422年
1433年
1439年
1450年
1461年
1467年
1478年
1489年
1495年
1506年
1517年
1523年
1534年
1545年
1551年
1562年
1573年
1579年
1590年
1601年
1607年
1618年
1629年
1635年
1646年
1657年
1663年
1674年
1685年
1691年
1702年
1713年
1719年
1730年
1741年
1747年
1761年
1767年
1778年
1789年
1795年
1801年
1807年
1818年
1829年
1835年
1846年
1857年
1863年
1874年
1885年
1891年
1903年
1914年
1925年
1931年
1942年
1953年
1959年
1970年
1981年
1987年
1998年
2009年
2015年

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