You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Can't get standard unix commands working

When I try

echo test > /User/user/Desktop/test.txt 


I just get the result:

zsh: no such file or directory: /User/user/Desktop/test.txt


Expected result is a text file on the Desktop containing the text "text".


MacBook Pro 16″, macOS 14.7

Posted on Dec 20, 2024 6:09 AM

Reply
11 replies

Dec 20, 2024 8:08 AM in response to G45User

It looks like this could be user error:


echo test > /User/user/Desktop/test.txt 


should instead be


echo test > /Users/user/Desktop/test.txt 


where of course "user" should be replaced by the actual username (matching the name of the account home folder).


Alternatively, the same could be achieved, more easily, like this:


echo test > ~/Desktop/test.txt 


because the tilde character is a standard Unix shortcut for the user home folder.


Dec 20, 2024 8:50 AM in response to G45User

You need to give the Terminal app access to the Desktop in the Files & Folders section of the Privacy & Security System Settings. The same also goes for the Documents & Downloads folders if you plan on accessing them. Most times macOS will prompt you to give permission for the Terminal, but sometimes it may not.

Dec 21, 2024 7:08 AM in response to G45User

The thread should be closed. It was really my typo User instead of Users. In fact, I was bitten by another Unix tool that was previously working and could no longer write due to Sonoma access restrictions. In trying to figure out why, I mistyped and thought that Sonoma even interfered with typing standard Unix commands, but I was wrong. Sorry about that.

Dec 21, 2024 8:42 AM in response to G45User

I've been using the Unix command line since 1985, and before that that VAX/VMS command line. I still make typo's. Thank goodness for command line recall. I did not have that in the early days of VMS and Unix usage.


Unix shells do have a nice trick that helps a lot. Type the first part of the file name, and then hit the "Tab" key, and if you have typed enough to be unique, the shell will fill out the rest of the file name. If it fills out the name, but that is not the name you are looking for, hit "Tab" again, and the shell will try another file with the same prefix. If nothing happens when you hit "Tab" either no files match the part you typed, or there are multiple matches, and hitting the "Tab" key again may give a list of all the partial matches.


Play with the "Tab" and you will get feel for how it works. It is a nice feature to add to your bag of tricks.


PS. And before that, it was 80-column punched cards. There is no command line recall with 80-column punched cards. You have to get the printout, find your made a mistake, re-punch the card, put it into your card deck, then take it back to the computer center, and wait for them to run your job again. So corrections can happen only a few times per day.

Dec 21, 2024 3:09 PM in response to BobHarris

Or paper tape… 😉 as was the case for my Fortran course in 197x.


The only value I got out of VMS was using the faster ACTnet at you know where to copy something from the left or right coast to my local ULTRIX or OSF/1 public folder. The VMS copy command did checksums so I could go home at night and the file would be transferred by the next morning.

Can't get standard unix commands working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.