Inserting a line at the end

Hi All,

I am using the below script to enter the URL at the end of file:

echo "Enter the URL that should point to the particular microsite"
read url
sed "$a $url" redirects.virgin-atlantic.com.conf > temp

But am getting the below error:

./script.sh[6]: [0: not found
Unrecognized command: Redirect permanent /kpmgxy system-unavailable

Please can you advise.

Best Regards,
Shazin

What is $a here? I am bit confused with your requirement.

If you just want to read and append a line to the end of a file, then try this.

 
echo "Enter the URL that should point to the particular microsite"
read url
echo $url >>filename

It's because $a is interpreted by the shell. You could use

sed '$a '$url redirects.virgin-atlantic.com.conf > temp

or much simpler

echo $url >> redirects.virgin-atlantic.com.conf

Hi,

Still getting the below error:

Enter the URL that should point to the particular microsite
Redirect permanent /kpmgxy system-unavailable
./script.sh[6]: [0: not found
sed: command garbled: $a Redirect
Redirects Setup

Best Regards,
Shazin

Hi,

There's something I don't understand.
is
redirects.virgin-atlantic.com.confthe name of the file? In this case, what is the use of
> temp?

Another question : this script is written for csh shell or ksh. How can I convert this for bash shell? All the Tuto i find use different syntaxes and don't works for bash shell...

If you have little time to explain me or a link to a good website, it'll be really appreciable.

Thanks

Are you sure you want to use "sed"?
Because, the syntax is wrong?

Or are you trying to use "cat"?
As per your requirement you must be using cat.

Rule 10: [...]Don't send a private message with a technical question. The forums are for the benefit of all, so all Q&A should take place in the forums.
Also, please learn how to enclose your code in appropriate tags. It's the '#' symbol above the posting box.

If you'd have posted the whole part before, not just the part where you thought the error was, we could have told you that the testing expression for the if requires whitespace surrounding the brackets, eg

if [ $? -eq 0 ]; then

Sorry and many thnks..... :slight_smile: