Grep and Awk.
If you're getting tired, this would be a good place to quit. Grep and Awk are very useful tools but not entirely trivial for mere mortals to use.
GREP
Grep lets you search a file for a string pattern and then spews
any lines that match the string anywhere to the screen. We
can find thisline in this html file using:
grep thisline grep.html.
And get these results:
can find thisline in this html file using:
Grep has several switches but the two I find most useful are -i which makes it case insensitive and -v which says to find any line which doesn't match the pattern.
AWK
According to the man page, awk is a "pattern scanning and processing language," but I most often use it to chop a file into columns and pull out, rearrange, whatever to the results.
The date command lets you print today's date in a specified format
such as:
/bin/date -u +%c%m%d
which gives: Tue Feb 06 15:49:52 20010206. (Use man date if you want
to learn more).
Now to just get a date string use:
/bin/date -u +%c%m%d | /bin/awk '{print $5}'
which produces: 20010206. We used awk here to print only the fifth column
of the output of date.
Now we can pipe this through julday to get the julian date:
/bin/date -u +%c%m%d | /bin/awk '{print $5}' | julday
which produces:
Calendar Date 02 06 2001
Julian Date 037 2001
We fed the fifth column of the output of date to the julday program.
Finally we can make a julian date string using:
/bin/date -u +%c%m%d | /bin/awk '{print $5}' | julday | grep Julian | awk '{print $4$3}'
resulting in:2001037. We fed the fifth column of the output of date to the julday
program then printed the fourth and third columns of the results.
Had enough? I warned you to quit earlier.