how should i do i mean scripting the unix program about adding data if it does not exist in file.txt I can do the psuedocode but not the actual code, anybody would give me a hand i would very very apprieciated! Your advice as always welcome.
if ( data from the commend-line is any letter case); then
tr the data from commend line and scan the data file which is
if [name found in file.txt]; then
elseif the tr data does not found in file.txt
echo no name found
add id, name. address, city, state > file.txt
if [ -z $1 ];
echo -n "write search string: "
lowerdata=`echo $data | tr '[:upper:]' '[:lower:]'`
echo "text file is $textfile"
echo "searching for $lowerdata"
found=`grep -r -l $lowerdata $textfile`
if [ $found == $textfile ];
echo "not found"
echo "adding new entry"
echo $data >> $textfile
use it with 2> /dev/null because of errors bla bla bla
anyway it is fully functional
you can use it like:
script.sh datahere 2> /dev/null
script.sh 2> /dev/null
and then it will ask for data (lame interactive mode )
also this will lowercase data
if you need it uppercase data then replace that tr code to
tr '[:lower:]' '[:upper:]'