|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
||||
Code:
#!/usr/bin/awk -f BEGIN { for (i=8; i<12; i++) system("cal" " " i " " 2011) } Code:
#!/usr/bin/awk -f BEGIN { for (i=8; i<12; i++) { while("cal" " " i " " 2011 | getline) print $0 } }
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
||||
If your numbers change often, you could make it an alias in .kshrc (or whatever shell you're using) as:
Code:
alias ca="awk 'BEGIN{for(i=ARGV[1]; i<ARGV[2]; i++) print \"cal \"i\" 2011\"}'" Code:
$ ca 5 12 Code:
$ cat <<eof>test.awk > #!/usr/bin/awk -f > > BEGIN{ > for(i=a; i<=b; i++) print "cal "i" 2011"} > eof $ ./test.awk -va=8 -vb=12 cal 8 2011 cal 9 2011 cal 10 2011 cal 11 2011 cal 12 2011
__________________
The best way to learn UNIX is to play with it, and the harder you play, the more you learn. If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD |
|
||||
Guys thank you so much. I realized how stupid I was as soon as I saw vermaden's answer. I cooked this based on your answers.
Code:
# This AWK script is written to automate generating of course calendar # used for my syllabi BEGIN {FS=" "; OFS=""; print "This program prints TeX calendar for the range of the months for the given year"; printf ("%s", "What is the year for which you want calendar? ") > "/dev/tty" getline year < "/dev/tty"; printf ("%s", "Enter the first month for which you want calendar as number [1-12]. ") > "/dev/tty"; getline first_month < "/dev/tty"; printf ("%s", "Enter the last month for which you want calendar as number [1-12]. ") > "/dev/tty"; getline last_month < "/dev/tty"; {for (i=first_month; i<=last_month; i++) system("cal" " " i " " year)} } {} Code:
\begin{center} \begin{small} \begin{tabular}{||l|l|l|l|l||l|l|l|l|l||} \hline \multicolumn{5}{||c||}{January}&\multicolumn{5}{c||}{February}\\ \hline \begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}\\ \hline \tiny{3} & \tiny{4} & \tiny{5} & \tiny{6} & \tiny{7} & \tiny{} & \tiny{1} & \tiny{2} & \tiny{3} & \tiny{4} \\ & & \tiny{Intro}& & & & &\tiny{1.4, 1.5} & & \\ & &\tiny{R.2, R.4} & & & & & & & \\ \hline \tiny{10} & \tiny{11} & \tiny{12} & \tiny{13} & \tiny{14} & \tiny{7} & \tiny{8} & \tiny{9} & \tiny{10} & \tiny{11} \\ \tiny{R.4, R.5}& &\tiny{R.7} & & & \tiny{1,6, 1.7} & & \tiny{2.1, 2.2} & & \\ & & & & & & & & & \\ \hline \tiny{17} & \tiny{18} & \tiny{19} & \tiny{20} & \tiny{21} & \tiny{14} & \tiny{15} & \tiny{16} & \tiny{17} & \tiny{18} \\ \tiny{MLK} & &\tiny{R.8} & & & \tiny{2.3} & & \tiny{2.5} & & \\ \tiny{Day} & & & & & & & & & \\ \hline \tiny{24} & \tiny{25} & \tiny{26} & \tiny{27} & \tiny{28} & \tiny{21} & \tiny{22} & \tiny{23} & \tiny{24} & \tiny{25} \\ \tiny{1.1, 1.2} & &\tiny{1.2, 1.3} & & & \tiny{3.1, 3.2} & &\tiny{Review} & & \\ & & & & & & & & & \\ \hline \tiny{31} & \tiny{} & \tiny{} & \tiny{} & \tiny{} & \tiny{28} & \tiny{} & \tiny{} & \tiny{} & \tiny{} \\ \tiny{\bf Exam 1} & & & & & \tiny{\bf Exam 2} & & & & \\ & & & & & & & & & \\ \hline \multicolumn{5}{||c||}{March}&\multicolumn{5}{c||}{April}\\ \hline \begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}& \begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}\\ \hline \tiny{} & \tiny{1} & \tiny{2} & \tiny{3} & \tiny{4} & \tiny{} & \tiny{} & \tiny{} & \tiny{} & \tiny{1} \\ & \tiny{Midterm}&\tiny{3.4, 4.1}& & & & & & & \\ & & & & & & & & & \\ \hline \tiny{7} & \tiny{8} & \tiny{9} & \tiny{10} & \tiny{11} & \tiny{4} & \tiny{5} & \tiny{6} & \tiny{7} & \tiny{8} \\ \tiny{4.3, 4.5}& &\tiny{5.4} & & & \tiny{No} & \tiny{No}&\tiny{No} &\tiny{No} & \tiny{No}\\ & & & & & \tiny{Classes}& \tiny{Classes}& \tiny{Classes}& \tiny{Classes}& \tiny{Classes}\\ \hline \tiny{14} & \tiny{15} & \tiny{16} & \tiny{17} & \tiny{18} & \tiny{11} & \tiny{12} & \tiny{13} & \tiny{14} & \tiny{15} \\ \tiny{6.1, 6.2}& & \tiny{6.3} & & & \tiny{Review} & & \tiny{\bf Exam 3} & & \\ & & & & & & & & & \\ \hline \tiny{21} & \tiny{22} & \tiny{23} & \tiny{24} & \tiny{25} & \tiny{18} & \tiny{19} & \tiny{20} & \tiny{21} & \tiny{22} \\ \tiny{6.4}& &\tiny{6.5} & & & \tiny{8.1}& & \tiny{Review} & & \\ & & & & & & & & &\\ \hline \tiny{28} & \tiny{29} & \tiny{30} & \tiny{31} & \tiny{} & \tiny{25} & \tiny{26} & \tiny{27} & \tiny{28} & \tiny{29} \\ \tiny{6.6}& &\tiny{6.7} & & & \tiny{Review}& &\tiny{Review}& & \\ & & & & & & & & & \\ \hline \end{tabular} \end{small} \end{center} |
|
||||
Welcome mate
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mount-msdosfs /dev/dao: : Invalid argument | harold | FreeBSD General | 5 | 12th December 2010 06:59 AM |
problem passing /dev/fd/n to programs | TerryP | Programming | 2 | 15th April 2009 08:24 AM |
Mount DVD - invalid argument. | maxrussell | FreeBSD General | 17 | 7th January 2009 08:46 AM |
Scripted sysinstall fails with "Command 'system' failed" | PeterSteele | FreeBSD Installation and Upgrading | 0 | 13th November 2008 11:31 PM |
passing arg from bootloadder to kernel | l2fl2f | FreeBSD General | 16 | 15th May 2008 12:38 PM |