Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `echo prefix = ~/.node >> ~/.npmrc` mean?

Tags:

linux

shell

unix

I'm reading this stackoverflow answer on running yo and npm without sudo by saving their results in ~/.node.

It uses echo prefix = ~/.node >> ~/.npmrc, and I'd like to know what each symbol means and how they work together in this case.

like image 639
randwa1k Avatar asked Feb 22 '14 02:02

randwa1k


1 Answers

echo prefix = ~/.node

This simply prints a string to standard output. The shell will expand ~ to the value of $HOME, so the string printed might be something like "prefix = /home/randwa1k" (without the quotation marks, of course).

... >> ~/.npmrc

This redirects the output of the echo command to the file ~/.npmrc, which expands to the same thing as $HOME/.npmrc. Using >> rather than > means that the output is appended to the end of the file.

So the command as a whole appends one line of text to a file called .npmrc in your home directory.

The effects of that change to the .npmrc file are going to depend on whatever programs read that file.

like image 174
Keith Thompson Avatar answered Sep 21 '22 12:09

Keith Thompson