All Questions
Tagged with shell-script macos
173 questions
0
votes
1
answer
38
views
mv command from launchd
I'm trying to accomplish a simple task and getting stuck. I've written a very simple script
#!/bin/bash
cd /Users/nathan/Downloads/
mv test test2
mkdir test
This works when I manually invoke it. But ...
0
votes
2
answers
217
views
Where to put my own shell scripts and configuration files? [duplicate]
Could anybody explain, in which directory (or directories) I should place my own shell scripts and configuation files on macOS?
/usr/local/bin/?
/usr/local/etc/?
$HOME/bin/?
$HOME/etc/?
... ?
A best ...
5
votes
3
answers
958
views
How can I assign a heredoc to a variable in a way that's portable across Unix and Mac?
This code works fine on Linux but not Mac OS:
#!/usr/bin/env bash
foo=$(cat <<EOF
"\[^"\]+"
EOF
)
printf "%s" "$foo"
It fails on Mac with
./test.sh: line 6: ...
0
votes
1
answer
88
views
Salesforce dataloader #!/bin/bash script errors mentions .zshrc
I'm trying to run a certain application (Salesforce dataloader v61) on MacOS.
The entry point is a bash script:
#!/bin/bash
DL_INSTALL_ROOT="$(dirname "$(readlink -f "$0")")&...
1
vote
1
answer
101
views
What does a leading colon in a sh script line means? [duplicate]
Looking inside macOS Homebrew installed cask Emacs file named emacs-nw used to start Emacs in terminal mode, I see the following script (see below).
What does the colon (':') at the start of the line ...
0
votes
1
answer
655
views
crontab /bin/zsh: can't open input file: test.sh
I am trying to create a crontab to run a script:
* * * * * cd /Users/test3/Desktop/Scripts/backup/ && /bin/zsh test.sh > /tmp/cron-output.log 2>&1
where test.sh is in /Users/test3/...
1
vote
1
answer
226
views
Open file manager to prompt user for file
I am writing a shell script that is meant to prompt the user for a file, and since I do not expect the end user of my script to be tech-savvy, rather than starting command line for interaction, I ...
1
vote
1
answer
133
views
Skip .app folders when using "fdupes" with the option "--recurse"
I am using fdupes to print the list of duplicate files in a certain folder, with the option --recurse.
However, since I am using macOS, the recursing process regards Mac apps (which appear to be ...
0
votes
1
answer
43
views
Editing PDF files from a list, from half a page to get a whole page from that one half
I have a PDF file that looks like this
----------
||----| |
||----| |
| |
| |
| |
|________|
with the help of the following commands
$ convert -density 300 -quality 100 -crop ...
0
votes
2
answers
52
views
Replace last nonblank line with a command output
I have a .env file like
PARAM1=val
PARAM2=val
I want to replace the last noblank line with another file content
So far I have something like below:
{ (sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' local.env | ...
0
votes
0
answers
95
views
Shell script: check for file doesn't work if there is a symlinked directory involved?
If I have
/mydir/myfile.txt
this code echos file already exists
if [ ! -f "/mydir/myfile.txt" ]; then
touch "/mydir/myfile.txt"
echo "created file"
else
echo ...
0
votes
2
answers
1k
views
Triggering "Reset Password" option in macOS Ventura for a specific account from the command line
I ran this command first to open the "Users and Groups" preferences on macOS Ventura:
open /System/Library/PreferencePanes/Accounts.prefPane
Next, I want to run a command that triggers the &...
3
votes
2
answers
2k
views
How can I save a text file with all command line inputs and outputs without saving the ANSI characters?
I am running the latest mac OS and using zshell, and having trouble writing a shell script. I do most of my work from the command line, and wanted to have a bash script automatically save and log all ...
1
vote
1
answer
972
views
$(echo "cd ..") Command not found
Good ol' -bash: cd ..: command not found.
I have a script I wrote to traverse up to a named directory. It had been working and now for the life of me I don't know what's changed.
$ type up
up is a ...
6
votes
3
answers
836
views
If no input URL is supplied use list from text file
I am trying to create a shell script for yt-dlp that takes an URL as input from the command line or if no input is given use an internal list. The script works when given input, but crashes when no ...