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 bottom of the file.
#!/bin/sh
grep -w "fred" file || printf "%s\n" "fred" >>file
Mart's method is the shell way. The 3GL Way is:
grep -w "$NAME" "$FILE"
TMP=$?
if [ "$TMP" = "1" ];
then
echo -e "$NAME\n" >> "$FILE"
fi
May I ask what the 3GL way is?
All that is 'shell' scripting, right?