Add to text file from command line via echo... possible to add to a particular line?[Scanned]
Chris Bradford
chrisbradford at cambridge-news.co.uk
Thu Jun 29 15:07:42 UTC 2006
Paul Howarth wrote:
> On Thu, 2006-06-29 at 07:42 +0100, Chris Bradford wrote:
>
>> Hi guys,
>>
>> I'm making a setup script for my Linux boxes that re-install Openldap
>> and some other bits and bobs. I need to add some text to /etc/pam.d/gdm
>> for example, and it needs to be on a particular line in this file, not
>> at the bottom.
>>
>> For example using the command:
>>
>> echo 'session required pam_mkhomedir.so skel=/etc/skel umask=0077'
>> >> /etc/pam.d/gdm
>>
>> Will only add this to the bottom of the file, can I get around this, it
>> needs to be on the same position on all machines, ie line 8.
>>
>
> How about:
>
> awk ' NR == 8 {
> printf "session required pam_mkhomedir.so skel=/etc/skel
> umask=007\n"
> }
> { print }' /etc/pam.d/gdm > /etc/pam.d/gdm.new
> mv /etc/pam.d/gdm.new /etc/pam.d/gdm
>
> Paul.
>
>
Paul,
Thats got it thanks :) I don't suppose there is a simple way to put a
yes/no question into the script, if answered yes another script will be
called, if no then its not?
Thanks again,
-Chris
This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
More information about the fedora-list
mailing list