Re: Add to text file from command line via echo... possible to add to a particular line?[Scanned]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Bradford wrote:
> Paul Howarth wrote:
>> On Thu, 2006-06-29 at 16:07 +0100, Chris Bradford wrote:
>>  
>>> 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?
>>>     
>>
>> There are some examples of reading user input here:
>>
>> http://www.hccfl.edu/pollock/AUnix1/fancyio.htm
>>
>> Paul.
>>
>>   
> Any ideas as to why this:
> 
> echo -n "Would you like to configure SophosAV: (type yes/no) "
> read ANSWER
> 
> if [ $ANSWER = yes -o YES ]
> then
>    echo 'good'
>    echo 'Enter script to run here....'
> 
> else
>    echo 'bad'
>    echo 'Carry on to next part of current script...'
> fi
> 
> Does not work?
> 
> Thanks,
> 
> -Chris
> 
> 
> This message has been scanned for viruses by BlackSpider MailControl -
> www.blackspider.com
> 
Change the if statement to
if [ $ANSWER = yes -o $ANSWER = YES ]

The way you have it is testing if $ANSWER = yes is true or if YES is
true, not if $ANSWER = yes or $ANSWER = YES is true.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux