I think your approach is bit wrong here to solve problem. Anyways I got working script for you, replace your existing code with following script:
Code:
#!/bin/sh
# mod() is function
# must be at top of script
mod(){
NCF="$CF.$$"
[ ! -f $CF ] && touch $CF || :
V="$1"
grep -v -E "^$V=" $CF > $NCF
mv -f $NCF $CF
eval echo "$V=\"'\${$V}'\"">> $CF
}
# config file
CF="file.txt"
URL=""
echo -n "Please enter new url"
echo "please include http:// in your address "
echo "EXAMPLE http://noobtutorials.co.uk"
read URL
# now change value for url
mod URL
echo -e "New url link is $URL "
echo -e "If you do not see http:// before www. please try again"
Variable CF stores file name, which you want to modify
Variable URL stores actual URL you want to setup
So script will ask for input i.e. new URL
Then function mod is called whice opens file stored in CF variable and replace or update URL it may have prefix http:// or without prefix http://
Quote:
|
whats the best way to remove the . at the begining,
|
Use any one of the following (cut is easy to use and small code):
Code:
find -name test | cut -d. -f2
find -name test | sed -e 's/\.//g'
find -name test | awk -F'.' '{ print $2} '
Quote:
|
Any ways i am really loving linux scripting have more pleasure out of this than any thing else ive done on my pc even ordered some books
|
Same here

Books are good, if you want to master programming, all you need to do is see good code (script

and practice it.