also sprach jeff <[EMAIL PROTECTED]> [2002.04.14.2235 +0200]: > for this example, i would like the output of 'dpkg -l' to be redirected > to a file called dpkg.html. at the end of every package decription, i > would like to add the <br> tag so it looks nice on the page.
dpkg -l | sed -e 's/$/<br>/' > dpkg.html dpkg -l "pipes into" sed, that is, all that dpkg writes to stdout appears at stdin of sed. sed is a stream editor, and it's a classic example of a UNIX "filter". such filters generally take in on stdin and write to stdout, modifying the data as they flow by. in this example, sed is instructed to execute the expression (-e) 's/$/<br>/', which is a replacement instruction. check the sed manpage for more info, or get started on perl. s/ basically says: replace everything between the first two slashes by everything between the last two. you could just as well use dots or anything else, e.g. [EMAIL PROTECTED]@<br>@, it's best to choose separators that are not in the search or replacement pattern. so the above replaces $ by <br>, which is not really correct actually. $ is a marker for the end of a line. it's not replaced because the end of line will simply be shifted so that "<br>" is inserted before. anyway, sed writes to stdout almost the same that dpkg wrote to stdout, except that sed inserted "<br>" at the end of each line. now the '>' sign instructs the shell to connect sed's stdout with a file, and the file is created and populated with sed's output. makes sense? to get into scripting, i suggest you play around with bash scripts and learn all the tools that come with UNIX, such as: sed, tr, cut, grep, cat, tac, sort, uniq to name just a few. then you might want to start looking at awk, or you might want to head for perl, which is the ultimate scripting language. -- martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" [EMAIL PROTECTED] your eyes are weary from staring at the CRT. you feel sleepy. notice how restful it is to watch the cursor blink. close your eyes. the opinions stated above are yours. you cannot imagine why you ever felt otherwise.
pgpZe1kCFEpm9.pgp
Description: PGP signature