Chris
Chris

Reputation: 14218

bash echo into another file not working

I want to append a line to another file from within my bash script:

#!/bin/bash
echo "xxx" >> ~/.bashrc

However I get:

bash: xxx: command not found

Upvotes: 0

Views: 1775

Answers (2)

Jens
Jens

Reputation: 72639

Could be it already worked, now you have an xxx command a the end of your ~/.bashrc and the next time it (bash) is invoked, it runs your .bashrc but can't find xxx. Is there an xxx command in your PATH?

Upvotes: 0

Zsolt Botykai
Zsolt Botykai

Reputation: 51603

Try it (the echo "xxx" >> part) from the CLI. It is likely caused by an improper file format (e.g. wrong encoding and/or windows line endings.

Also cat -a SCRIPTNAME might give some insight.

Upvotes: 1

Related Questions