Let's say I make a file .history.txt:
touch .history.txt and I try to write to it:
cat > .history.txt after having done that all I get is:
bash: .history.txt: is a directory What I need is to be able to write some text to it like I would be able to any normal file. Any ideas what am I doing wrong?
101 Answer
A file doesn't need to already exist in order to redirect output to it (the shell will create the file if necessary). But Bash is telling you that .history.txt already exists and is a directory, so you can't write to it.
You either need to remove the existing directory rm -rf .history.txt or use a different file name. Then cat > .whatever.txt should work on its own.