Congratulations Onward and upward. HM On 03/05/2015 09:31 PM, Michael Havens wrote: > Well, I know no one will really care but me but I have to share! > > I decided to follow the TLDP manual/workbook to learn BASH. I came to > this decision for a couple of reasons: the first being that it is > likely the most authoritative and the second was they have exercises > whereas the IBM pages didn't. > > Well, I read the first chapter and got to the exercises. The project > was to write a script that would print the date and time, who is > logged in, and what the uptime of the system is; the I am supposed to > ake all of that and print it to a file. > > I thought to myself, "But they haven't taught us anything!" I was > about to write to the user group I am part of and ask my infamous "how > do I" question when I stopped, took a breath, and figured I should at > least try to work it out on my own. So I figured the first line is a > pound sign and exclamation point but I was unsure of the order; was it > !# or #!. So it just so happens that this sequence of characters is > called a sha-bang so the exclamation point must come second. I'll try > that first. > Then I burned some brain cells trying to figure how to run multiple > commands and print it all to a single file. I tried encapsulating > everything with curly brackets ({ }) but that gave an error of some > sort. Finally, after a couple of minutes, it came to me that they > probably want their readers to use a favorite search engine > (duckduckgo in my case). So after entering the parameters of the > search some hits came up and after looking through a few I found one > that fit my question. How could I not have realized how to do this? It > is merely using the append file redirection (>>)! So this is what I > wrote: > > #! /bin/bash > date >>& > who >>& > uptime>> > done > > Luckily I realized that for there to be a 'done' there also needs to > be 'do'. There is no 'do' therefore we don't need the 'done'. > So I ran the program and everything seemed to run without error, > however, did it write the data to a file? I then go back to the > terminal and type 'more '. Look at that! Everything is there. > > Thu Mar 5 20:44:36 MST 2015 > 20:44:36 up 9 days, 1:45, 2 users, load average: 0.52, 0.55, 0.73 > bmike1 tty8 2015-02-24 19:00 (:0) > bmike1 pts/2 2015-03-05 20:22 (:0.0) > > :-)~MIKE~(-: > > > --------------------------------------------------- > PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org > To subscribe, unsubscribe, or to change your mail settings: > http://lists.phxlinux.org/mailman/listinfo/plug-discuss