1

I've got a bash script in which i create a file and append to it. Problem is when I try to write to it, the shell tells me

/home/username/bin/myscript: line 62: ~/Desktop/folder/filename: No such file or directory

The script part is:

57: mkdir ~/Desktop/folder
58: touch -a ~/Desktop/folder/$1
59: chmod 774 ~/Desktop/folder/$1

61: addr=$(cat $D/$1/address)
62: echo "$addr">>"~/Desktop/folder/$1"

When I go look for the file, it appears in the ls command with the correct permissions. It also appears correctly in the file explorer.

I've tried changing between cat and echo commands to append to the file but neither works.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
user309697
  • 11
  • 1
  • See this similar question: [mkdir: cannot create directory: No such file or directory](https://unix.stackexchange.com/questions/419448/mkdir-cannot-create-directory-no-such-file-or-directory) – steeldriver Sep 08 '18 at 00:53

1 Answers1

0

Try to do this on line 62:

$ echo "$addr" >> ~/Desktop/folder/"$1"
Bon Ami
  • 883
  • 2
  • 10
  • 14