LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Unix scrpting : Append to a file (https://www.linuxquestions.org/questions/programming-9/unix-scrpting-append-to-a-file-452806/)

linux_newbee 06-08-2006 08:17 AM

Unix scrpting : Append to a file
 
I am trying to write a Unix script which does the following:

Append the
Code:

alias myserver='/usr/bin/myserver :$SOME_USERID -name  $SOME_USERNAME'
to the end of a particular file.

Can anyone help me with doing this ?

I tried the following
Code:

echo "alias myserver='/usr/bin/myserver :$SOME_USERID -name $SOME_USERNAME'" >> .bashrc
But i am getting the following
invalid command name "echo"
while executing
"echo "alias
  1. Why is this happening ?
  2. Any other way to do the appending ?

Thanks in advance

macemoneta 06-08-2006 08:23 AM

You've apparently defined an alias for echo. To display all your aliases:

alias

To remove an alias (also remember to remove it from any scripts executed at login):

unalias echo

marozsas 06-08-2006 09:21 AM

The left slash prevents an alias expansion for the following command.

Code:

$ \echo "whatever..."
will execute the internal bash echo, not an alias.

linux_newbee 06-08-2006 11:58 PM

No i am not trying to create an alias for echo. I am trying to create an alias for "myserver"

muha 06-09-2006 04:19 AM

You're trying to do this right?
Code:

$ cat > file
test <CTRL+D>
$ echo "alias myserver='/usr/bin/myserver :\$SOME_USERID -name \$SOME_USERNAME'" >> file
$ cat file
test
alias myserver='/usr/bin/myserver :$SOME_USERID -name $SOME_USERNAME'


linux_newbee 06-12-2006 06:14 AM

Yes.... this is what I am trying to do. This "file" is a script file. So i try to execute the file after i put the echo commands. but it gives me the error....
" invalid command name "echo" while executing "

marozsas 06-12-2006 08:02 AM

Quote:

Originally Posted by linux_newbee
No i am not trying to create an alias for echo. I am trying to create an alias for "myserver"

Yes, we understand this.
What we are talking, is maybe, there is, for some reason, an incorrect alias to echo.

try to put, as macemoneta pointed, "unalias echo", right before the echo "alias=whatever" in your script.


All times are GMT -5. The time now is 01:32 PM.