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

2010-04-09 Thread Jasper
if I only execute one command on true/false conditions, I prefer: command react_true || react_false Although this generally works it is not correct: If 'react_true' fails for some reason then 'react_false' is also executed. --Jasper. -- To UNSUBSCRIBE, email to

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

2010-04-09 Thread Mart Frauenlob
On 09.04.2010 16:50, Jasper wrote: if I only execute one command on true/false conditions, I prefer: command react_true || react_false Although this generally works it is not correct: If 'react_true' fails for some reason then 'react_false' is also executed. --Jasper. oops,

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

2010-04-08 Thread Mart Frauenlob
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 fredfile Why not simply use echo fred file for the second command? 1: I'm used to it. 2: saving me typing (quick web search):

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

2010-04-08 Thread Mart Frauenlob
On 07.04.2010 23:12, Ron Johnson wrote: On 2010-04-07 15:45, Mart Frauenlob wrote: On 07.04.2010 22:10, Kent West wrote: [...] I want a script that will read the file and look for the name fred, and if it's found, leave the file alone, but if it's not found, to add the name fred to the

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

2010-04-08 Thread Mart Frauenlob
On 08.04.2010 00:49, Ron Johnson wrote: On 2010-04-07 16:12, Ron Johnson wrote: [snip] Mart's method is the shell way. The 3GL Way is: grep -w $NAME $FILE TMP=$? if [ $TMP = 1 ]; That should be: if [ $TMP = 0 ]; then echo -e $NAME\n $FILE fi nope, the OP wanted 'if

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

2010-04-08 Thread Ron Johnson
On 2010-04-08 03:03, Mart Frauenlob wrote: On 08.04.2010 00:49, Ron Johnson wrote: On 2010-04-07 16:12, Ron Johnson wrote: [snip] Mart's method is the shell way. The 3GL Way is: grep -w $NAME $FILE TMP=$? if [ $TMP = 1 ]; That should be: if [ $TMP = 0 ]; then echo -e $NAME\n $FILE

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

2010-04-08 Thread Ron Johnson
On 2010-04-08 03:01, Mart Frauenlob wrote: On 07.04.2010 23:12, Ron Johnson wrote: On 2010-04-07 15:45, Mart Frauenlob wrote: On 07.04.2010 22:10, Kent West wrote: [...] I want a script that will read the file and look for the name fred, and if it's found, leave the file alone, but if it's

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

2010-04-08 Thread Ron Johnson
On 2010-04-08 02:56, Mart Frauenlob wrote: [snip] 2: saving me typing (quick web search): http://unix.derkeiler.com/Newsgroups/comp.unix.shell/2006-12/msg00934.html Interesting. -- History does not long entrust the care of freedom to the weak or the timid. Dwight Eisenhower -- To

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

2010-04-08 Thread Mart Frauenlob
On 08.04.2010 14:58, Ron Johnson wrote: On 2010-04-08 03:01, Mart Frauenlob wrote: On 07.04.2010 23:12, Ron Johnson wrote: On 2010-04-07 15:45, Mart Frauenlob wrote: On 07.04.2010 22:10, Kent West wrote: [...] I want a script that will read the file and look for the name fred, and if it's

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

2010-04-07 Thread Mart Frauenlob
On 07.04.2010 22:10, Kent West wrote: I'm asking you folks, 'cause y'all know this stuff (I've been wrestling with this simple task all day). I've got a text file; I just want a script (a one-liner sed or awk command, etc, would be awesome) to check to see if the file contains a certain

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

2010-04-07 Thread Kent West
Mart Frauenlob wrote: On 07.04.2010 22:10, Kent West wrote: I'm asking you folks, 'cause y'all know this stuff (I've been wrestling with this simple task all day). I've got a text file; I just want a script (a one-liner sed or awk command, etc, would be awesome) to check to see if the file

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

2010-04-07 Thread Ron Johnson
On 2010-04-07 15:45, Mart Frauenlob wrote: On 07.04.2010 22:10, Kent West wrote: I'm asking you folks, 'cause y'all know this stuff (I've been wrestling with this simple task all day). I've got a text file; I just want a script (a one-liner sed or awk command, etc, would be awesome) to check

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

2010-04-07 Thread Eduardo M KALINOWSKI
On 04/07/2010 05:45 PM, Mart Frauenlob wrote: #!/bin/sh grep -w fred file || printf %s\n fredfile Why not simply use echo fred file for the second command? -- All men have the right to wait in line. Eduardo M KALINOWSKI edua...@kalinowski.com.br -- To UNSUBSCRIBE, email to

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

2010-04-07 Thread Ron Johnson
On 2010-04-07 16:12, Ron Johnson wrote: [snip] Mart's method is the shell way. The 3GL Way is: grep -w $NAME $FILE TMP=$? if [ $TMP = 1 ]; That should be: if [ $TMP = 0 ]; then echo -e $NAME\n $FILE fi -- History does not long entrust the care of freedom to the weak or the