Re: OT: Script to add line to file if it doesn't exist



On 07.04.2010 23:56, Eduardo M KALINOWSKI wrote:
On 04/07/2010 05:45 PM, Mart Frauenlob wrote:

#!/bin/sh
grep -w "fred" file || printf "%s\n" "fred">>file



Why not simply use
echo "fred" >> file
for the second command?


1: I'm used to it.

2: saving me typing (quick web search):
http://unix.derkeiler.com/Newsgroups/comp.unix.shell/2006-12/msg00934.html

I know the example of the OP is simple, but most likely 'fred' will
become a variable.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
Archive: http://lists.debian.org/4BBD8C33.2070908@xxxxxxxxx



Relevant Pages

  • Please dont cause unneeded traffic for TOR
    ... Thank you for saving me the typing. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
    (Debian-User)
  • Re: wheezy after update significant slow
    ... When starting konqueror and visiting sites with pictures on it, ... Typing an URL in konqueror let the process Xorg increase from 12 percent to ... Related to the libreoffice-effect, there is on from ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: map - to _ and _ to -
    ... On Fri, Nov 12, 2010 at 2:02 AM, Kamaraju S Kusumanchi ... Typing '_' involves holding the shift key while typing '-' does not involve ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: X11 Forwarding with Lenny?
    ... I had the same problem on 3 machines I upgraded from etch to lenny. ... (The second command shows your sshd configuration; ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Clearing SWAP
    ... my wife doesn't like typing, she likes clicking mice. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)