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



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.

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Re: match machine name to user name
    ... :>: query the server from a client for a username based on a machine name. ... :> It reads better if you post inline or at the bottom. ... Is it better to use the script to poll the server or to ...
    (microsoft.public.scripting.vbscript)
  • Re: match machine name to user name
    ... > dim strComputer, oConn, colComputer, oComputer, oLocator, sUser, sPass ... > set oArgs = wscript.arguments ... I will be running the script from my machine. ... so I guess I am used to reading 'bottom up'. ...
    (microsoft.public.scripting.vbscript)
  • Re: chopping off the last few lines.
    ... > various pre-processing actions upon it via a ksh script. ... bottom of a file. ... ## The bufarray is a rotating buffer which contains the last N lines ...
    (comp.unix.shell)
  • Re: random selection
    ... > rows - not from the top or bottom. ... I'm also surprised that you're joining on posteddate... ... I have written the following script to select the ... > t.PMIDNAME from tablecates t (nolock) inner join eRecords ...
    (microsoft.public.sqlserver.server)
  • Re: Drawing origin
    ... manual intervention for each drawing. ... What defines the 'bottom left of each drawing'? ... script on several files. ... I am using "Batch Script Processor v3.0.11" as a batch processor and I ...
    (comp.cad.autocad)