-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 18-Sep-2002/17:12 -0700, smoke <[EMAIL PROTECTED]> wrote: >id like to append something to the beginning of each >line on a file. [snip]
If you want to insert it at the beginning of the line, it's "prepend", not "append". You want to read a list of host names from a file and prepend 'www' to any name that does not already start with 'www'. Try this: #!/bin/sh for line in `cat hostlist.txt`; do if echo $line | grep '^www' > /dev/null; then # Line already begins with 'www'. # Output the line to the new file as-is. echo $line >> hostlist-www.txt else # Line does not begin with 'www'. # Prepend 'www' and output the line to the new file. echo www.$line >> hostlist-www.txt # Increment the counter so we know how many lines were modified. let ctr=$ctr+1 fi done echo "Added www to $ctr hostnames." Tony - -- Anthony E. Greene <mailto:[EMAIL PROTECTED]%3E> OpenPGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D AOL/Yahoo Messenger: TonyG05 HomePage: <http://www.pobox.com/~agreene/> Linux. The choice of a GNU generation <http://www.linux.org/> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Anthony E. Greene <mailto:[EMAIL PROTECTED]> 0x6C94239D iD8DBQE9iUZ/pCpg3WyUI50RAm+RAKDVbLWCZWglMt/96ftYLygkkdEkaQCgqeB5 PuIKaAIUdMMJ5JNQcGhNqJA= =1e/1 -----END PGP SIGNATURE----- -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list