Hi All,
I am looking for a terminal command to get the exact same output as the file count you recieve when using Get Info in finder.
The closest i can get is using the find command with flags:
find 'path/to/folder' -not -path '*/\.*' -and -not -path '*\.key/*' -and -not -path '*\.numbers/*' -and -not -path '*\.pages/*' -and -not -path '*__MACOSX/*' -and -not -path '*\.pdf/*' -and -not -path '*\.app/*' -and -not -path '*\.rtfd/*' | wc -l
I will be searching on an external volume that sometimes produces keynote save files that finder sometimes sees as a package and sometimes sees as a folder. If a folder finder counts the items contained if a package it doesn't, I need the command or script to mimic this behaviour.
In the example of the screenshot get info on the top folder produces a count of 14 and the find command produces a count of 23.
There are also other behaviours that differ the file count between them but i'm not sure what causes them.
Any help on a solution it being a command or script would be much apreciated.
Thanks,
James
How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here
Zsh
RSS for tagThe Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting.
Posts under Zsh tag
7 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I installed MacOS Sequoia 15.4 and now my backup script no longer works.
My script is using rsync in this way:
rsync -avz —delete —log-file=“$LOG_FILE” “$SRC_DIR” “$DEST_DIR”
This has been working fine for a very long time.
After updating to 15.4, this produces the error “rsync: unrecognized action —log-file=/users/admin/logs/backuplog_xxx.log”.
The log file path is correct (and hasn’t changed).
Interestingly, the man page for rsync no longer shows the —log-file as an option.
I know I can use:
rsync -avz —delete “$SRC_DIR” “$DEST_DIR” > “$LOG_FILE”`
or even
rsync -avz —delete “$SRC_DIR” “$DEST_DIR” > “$LOG_FILE” 2>&1`
to also capture stderr.
However, I liked the output from the built-In log option.
Does anyone know why this might have been removed or if there is a way to get it back?
Thanks.
Hey, I am using the terminal a lot. Since I updated to Sonoma (so, really a long time ago). My prompt or more precise the hostname always changes between three states. Sometimes it is username@Macbook-Pro-of-XXX, sometimes username@MacbookPro and sometimes it's username@xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb. The latter is probably my UUID. Does anyone have a clue why this randomly changes?
I updated my computer to Sonoma, and now my LaunchDaemon will not load.
I have the following setup :
File in /Library/LaunchDaemons/com.startup.plist
like this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.startup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/bash</string>
<string>/Library/Scripts/Startup/startup.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/com.startup.stderr</string>
<key>StandardOutPath</key>
<string>/tmp/com.startup.stdout</string>
</dict>
</plist>
File in File in /Library/Scripts/Startup/startup.sh
#!/bin/zsh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users:/Users/root:/Users/root/Scripts:/Library/Scripts:/Library/Scripts/Startup
#Load modules for Fuse
/Library/Filesystems/macfuse.fs/Contents/Resources/load_macfuse
/usr/sbin/sysctl -w vfs.generic.macfuse.tunables.allow_other=1
#Connect to XXXXXX_net
/bin/sleep 28
myip=0
while [ $myip = 0 ]
do
/bin/sleep 3
myip=$(ifconfig -l | xargs -n1 ipconfig getifaddr)
done
/usr/local/bin/sshfs XXXX@XXXXXX.net: /Volumes/XXXXXX.net -o local,auto_cache,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,ConnectTimeout=5,daemon_timeout=60,iosize=2097152,volname=XXXXXX.net,allow_other,defer_permissions,async_read,Ciphers=aes128-gcm@openssh.com,Cipher=aes128-gcm@openssh.com,compression=no
And then we need some commands to be run as root user during boot :
/private/etc/sudoers.d/startup-script-nopasswd
username ALL = (root) NOPASSWD: /usr/sbin/sysctl
username ALL = (root) NOPASSWD: /usr/local/bin/sshfs
As of now, I cant even get the /Library/LaunchDaemons/com.startup.plist
to run after i updated the macOS to Sonoma ….
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
macOS
Zsh
Scripting
Command Line Tools
I often need to remotely control a Mac that has the Remote Desktop application running on it. Thus I need to create a script to kill it remotely. The following command gives me the process number (PID) on the remote machine when logged in via SSH. What I need to know is how to pass that number to kill -3 to quit it with one command, bad thing can happen if you make a typo on PID
ps -ax | grep "Remote Desktop.app" | grep -v grep | awk '{print $1}'
I write programs to do calculations. In order to automate some things I setup my Mac to consume a queue of jobs and a cron will check the queue and then run them through.
I noticed that cron jobs run so much slower.
As root I am running all the commands at nice -n -100 (yes I know -20 is the limit)
if I run this command from the terminal it take 62 seconds. Checking the ps this is what I see:
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME
0 17826 17195 4006 0 31 -20 413217088 581472 - R<+ 0 ttys000 16:11.07 /usr/local/bin/M 0.358 12:41PM
Now comparing that to the cron'd job this same calculations will take 441 seconds. The ps comes out to:
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME
0 18231 18230 4004 0 20 -20 411514512 515632 - R< 0 ?? 28:16.72 /usr/local/bin/M 12:47PM
This is 7x slower!
Both processes are at -20 NICE, but the priority for the cron job is 20 while running from terminal is 31. So I am guessing that priority is the mitigating factor here.
I can't seem to figure out how to change the priority of the job. Lots resources out there just seem to think by changing nice you also change priority. But that is not the case.
The question I have is how do I change the priority of a cron job (or any job in fact).
I am running on a MacBook Pro (2013). I was thinking maybe Apple Mac Pro desktops could be setup differently but I just don't know.
I have a command line tool that zsh refuses to run when built for Apple Silicon or as a univerisal binary (the specific message is zsh: killed TOOL_NAME). I can only get it to run if I build it exclusively for Intel/Rosetta.
Running/debugging from within Xcode works fine for any architecture.
The tool is a very simple C/C++ unix command-line tool; it doesn't have any external dependencies beyond the C runtime and the C++ STL.
I suspect something in code signing is going awry, but I've tried various team and certificate combinations without any luck. I've also tried enabling/disabling the app sandbox, also without any luck. (The app is not for distribution so it doesn't really need to be code signed at all.)
Any suggestions?