Questions tagged [bash]

The Unix shell formerly used by Terminal in macOS until 10.15

Filter by
Sorted by
Tagged with
1 vote
1 answer
17 views

need to turn separate zsh script into a function inside a master script

I'm trying to turn 6 scripts into one script, so that instead of the enduser needing to download 6 scripts, do chmod +x mess to them etc, and then run the master script, they'd only need one script ...
user avatar
  • 1,090
0 votes
1 answer
67 views

Most homebrew installed commands outputs "zsh: killed"

When I type brew, I get the output: zsh: killed brew Writing out the whole path still gives the same output, so it doesn't seem like a path problem. Furthermore, running /bin/bash gives the ...
user avatar
0 votes
0 answers
42 views

Installer is getting failed while running post install script

The installer is getting failed while running the post-install script with error: *** Couldn't posix_spawn: error 2 We are importing the certificate in the post-install script for validation. ...
user avatar
0 votes
1 answer
39 views

Interpreting AppleSmartBattery manufacturing date from ioreg in macOS Big Sur and later

I am trying to make sense of the age of the battery (by calculating it from its manufacturing date). I need the information for something I am working on and need to know how to access it ...
user avatar
  • 101
2 votes
2 answers
88 views

In Terminal, using the "touch" command to mass create consecutive files with leading zero's, with bash, produces different results than zsh

In Terminal, I prefer to use bash as my default shell. Issuing the command touch File_{01..10}.txt produces these results: File_1.txt, File_10.txt, File_2.txt, File_3.txt, File_4.txt, File_5.txt, ...
user avatar
  • 6,309
1 vote
1 answer
43 views

Bash script or AppleScript to connect & disconnect an Airplay display in Monterey+

In System Preferences > Displays, bottom left corner is "Add Display". I can choose another (Monterey+) Mac, Apple TV, iPad, possibly other things, to effectively become an additional ...
user avatar
  • 378
1 vote
2 answers
68 views

What is '<<EOS' in shell commands like 'osascript <<EOS'

In this post and one or two others I've seen things like: osascript <<EOS -- some AppleScript code EOS I expect it's part of bash and presumably other shells... or is it an AppleScript/...
user avatar
  • 378
0 votes
1 answer
30 views

My PS1 Customized Terminal Prompt doesn't work on MacOS [duplicate]

I moved from Windows and my customized terminal prompt doesn't work anymore, I'm trying to figure out the reason for that. It's not working in iTerm2 or RoyalTSX or Terminal. On windows: export PS1=&...
user avatar
  • 103
0 votes
0 answers
25 views

Why does setting my MAC address take two attempts?

I'm new to SE so I'm not sure if this is the correct site, but I am trying to change my MAC address to a fixed value on startup of macOS using zshell (bash should be similar or the same ). I oddly ...
user avatar
0 votes
0 answers
35 views

BASH vs Python? Is BASH slow? Or is it On-Site Server?

I'm fairly new to writing scripts, so this might be a really amateur question. My job consists of a lot of copy/sorting/downloading/indexing files on an on site server while I work from home. So ...
user avatar
0 votes
0 answers
43 views

How does Firefox send link to external application?

I want Firefox to call a bash script to open a certain type of URL. I've created a directory MyScript.app and put an executable bash script MyScript into it. When clicking a link, Firefox asks to ...
user avatar
  • 123
2 votes
1 answer
35 views

Return control to bash script when using /usr/bin/open to close SSH tunnel

I want to write a bash script that: establishes an SSH tunnel launches a local VNC client (vncviewer, the RealVNC viewer in my case) closes the SSH tunnel once the vncviewer exits Best effort so far:...
user avatar
  • 123
1 vote
1 answer
43 views

How can I inspect the environment variables of a running process in Big Sur?

How can I see env vars of a running process? The solution from here doesn't seem to work: ➜ ~ TEST=test /bin/bash -c 'sleep 1000 && echo $TEST' & [1] 27677 ➜ ~ ps eww 27677 PID TT ...
user avatar
  • 51
0 votes
0 answers
14 views

MacOS Monterrey will not run shell scripts [duplicate]

I use shell scripts a lot. Ever since upgrading to OS Monterrey 12.3.1, none of my shell scripts will run. They are in the same locations they were before the upgrade to Monterrey. I execute a shell ...
user avatar
0 votes
0 answers
60 views

zsh: command not found (some modules)

I used bash and installed different packages. But when i install zsh, some modules are missing, for example (angular cli, nvm - node version manager), but detected npm and node js. Why is this ...
user avatar
0 votes
0 answers
42 views

Debugging phantom zsh process

Every once in a while (once a week?) I noticed that my mac's fans are spinning full speed. When I investigate my processes on activity monitor I notice a zsh process consuming near 100% on the cpu. ...
user avatar
  • 121
1 vote
0 answers
27 views

Sed command to replace values on custom lines

I'm trying to replace custom values in a configuration file using sed, but the changes should be applied for specific indexes of lines (e.g. first two lines only, line 3, etc). For now, using this ...
user avatar
  • 111
0 votes
2 answers
123 views

Setting up env command for bash scripts

I am using Big Sur for work. I want to write a bash script that uses some modern bash features. The bash that comes with Big Sur is fairly old: $ /bin/bash --version GNU bash, version 3.2.57(1)-...
user avatar
1 vote
1 answer
52 views

Using Find, Execdir, and Grep all in one command

I'm trying to use a shell script to: return all .mov files in a given directory without path, file names only filtering out dot-underscore files from results separate each result by \n but haven't ...
user avatar
0 votes
0 answers
87 views

Macbook Pro producing mail in terminal. How can I stop this?

Terminal has been producing mail from an unknown script that I cannot track down. Message below: Any ideas on how to stop this from sending me messages?
user avatar
  • 1
0 votes
2 answers
136 views

Natural Text Editing is not working in iTerm2

I've seen dozens of articles that talk about making terminal life better by switching to iTerm2 and then turning on "Natural Text Editing" under Profile > Keys. Then you can use the ...
user avatar
  • 121
0 votes
0 answers
22 views

Where should I put the PATH to my custom scripts folder? [duplicate]

I have a folder with my handy shell scripts, called bin, and placed in my home: /Users/<my_home>/bin Every time I open a terminal (be it with the Terminal app, or with iTerm, or from VS Code, ...
user avatar
  • 377
0 votes
0 answers
29 views

~/.ssh/rc is not executed when using ssh

I'm in the situation of having to connect to various systems via ssh to do some quick work and then leave without a trace. Before I do any work, however, I would like to set up some aliases to save ...
user avatar
0 votes
1 answer
34 views

How to properly check if a variable is empty

I have created a function to test if an app is installed or not: function test_app_installed { local installed_app_to_search="$1" local installed_app_search_name ...
user avatar
1 vote
0 answers
24 views

Why is LANG environment variable wrong in shell?

When I start a Terminal (in Monterey 12.2.1) my LANG is sv_SE.UTF-8, which is fine. When I start a shell, or any other sub-process that reads environment, from GUI Emacs it is set to LANG="en_SE....
user avatar
  • 141
2 votes
1 answer
514 views

Terminal ls command does not list complete contents of /Applications

In Terminal.app, I issue the following commands: cd /Applications ls It lists many, but not all, of the apps that the Finder sees. The ones it appears to omit are all Apple, but it doesn't omit all ...
user avatar
  • 1,060
0 votes
0 answers
27 views

How to batch update finder tags, date created, and date modified on copied files based on original/reference files

I'm trying to update finder tags, date created, and date modified on files that were incorrectly copied to a new server, stripping all of these attributes. I still have access to the original server ...
user avatar
2 votes
2 answers
270 views

How do I debug zsh when startup performance is slow?

I'm using Z shell inside iTerm2 every time I open up a new window or a new tab it takes around 8 - 9 seconds to load. I found some information on how to debug zsh. I came across this Speeding Up My ...
user avatar
0 votes
1 answer
41 views

In iTerm how can I close a shell session when the running command finishes?

I open some iTerm2 sessions via ttab. I start these session for textual UI commands like top or commands which might run for a long time like cp -r <large-dir> <backup-location>. After the ...
user avatar
  • 1,198
2 votes
1 answer
67 views

Change creation date to folder name - batch

Hi I have a load of jpg and avi files in sub folders which are named with the date the files were created. Unfortunately the files themselves have incorrect creation dates which I would like to batch ...
user avatar
0 votes
2 answers
105 views

how to change extended attributes on mac recovery

xattr worked on mac desktop system but I want to let it work in mac recovery terminal but xattr is not included in bash of terminal I copy xattr to usb drive and run it on recovery terminal ,but it ...
user avatar
9 votes
2 answers
743 views

Updating just Safari through terminal on Big Sur

There is a new version of Safari and I'm trying to update just Safari on my machine using a terminal command. I have Big Sur 11.6.3. I've done Softwareupdate -l and I see the Safari update there. I ...
user avatar
  • 171
0 votes
1 answer
41 views

Defined bash commands not found when passed in "do shell script" in osascript

I am new to shell script and recently wrote a script to open a new terminal window and run defined functions via osascript with "do shell script", but the result showed the command not found....
user avatar
1 vote
1 answer
46 views

Prepend folder names to file name

I'm trying to add the folder name to the names of the files contained in the folders and sub-folders. @nohillside has already provided a command which solves partly this problem; see Prepend folder ...
user avatar
  • 11
1 vote
1 answer
75 views

update/upgrade bash without homebrew

I have MacOS El Capitan - about bash it is: bash --version ... version: 3.2.57(1)-release ... I did realise the mapfile command is not available in that bash release. I already did do research and ...
user avatar
0 votes
1 answer
25 views

I'd like to change the shell script instruction to the one available in the terminal

do shell script "bless -mount /Volumes/BOOTCAMP/ -legacy -setBoot -nextonly" password "0000" with administrator privileges tell application "System Events" restart ...
user avatar
0 votes
1 answer
22 views

'grep --color' only shows limited number of matches and duplicates input lines

I have a lengthy string on one line and want to highlight all occurrences of a character/substring using grep --color on the command-line. However, this only highlights matches in 'chunks' of 32. If ...
user avatar
  • 3
0 votes
1 answer
55 views

Alternative for getent to launch containerized ShinyProxy with a docker engine

I'm following this tutorial to launch a containerized ShinyProxy with a docker enine. It works as expected, until there is this getent command that seems to be unavailable for MacOS :( sudo docker run ...
user avatar
0 votes
0 answers
26 views

Bring PID's window into focus from Bash script

I'm writing a little script to run when a Windows/Wine-turned-macOS(using-Automator) app is opened. To keep it light, the app does not bundle Wine, instead the script checks if it's (Wine) installed ...
user avatar
  • 163
0 votes
3 answers
346 views

macOS doesn't run executable file anymore, after upgrade to Catalina/Monterey

Since I upgraded to Monterey (from Mojave), I cannot run anymore a local server that was installed under /Applications. The app has no extension, the file type is "Unix Executable File". It ...
user avatar
1 vote
2 answers
131 views

How do I get env variables to load on terminal startup? [duplicate]

It should be noted that I am on MacOS 12.0.1 and I'm looking to add some persistent environment variables. I have seen posts about creating and adding to ~/.bashrc or ~/.bash_profile but I'm not sure ...
user avatar
0 votes
1 answer
263 views

MacOS: How to delete network services from command line?

I have several dozens of non-existent network services that appear in the network panel in System Preferences. I have generated a list of network services with: networksetup -listallnetworkservices ##...
user avatar
  • 2,194
5 votes
1 answer
292 views

Tail terminal command is extremely slow when processing files with long lines

The tail command has become unusably slow for large files (e.g. 1 GB text file). EXAMPLE: $ tail -265000 file.txt > last_265000.txt takes 10+ minutes, whereas $ head -265000 file.txt > ...
user avatar
  • 161
2 votes
1 answer
349 views

zsh does not find script in PATH while bash does (echo $PATH is the same)

I am trying to execute a script using just its name. So naturally I added it to the PATH variable. But it seems zsh does not care. If I switch to bash everything works fine. The following terminal ...
user avatar
  • 245
1 vote
1 answer
86 views

under macos 10.15.7, why cannot cron find files on my external hard drive? [duplicate]

I purchased an external hard drive for scheduled backups of my macbook pro, presumably under cron. My rsync commands work fine when I invoke on the bash (interactive) command line. But as soon as I ...
user avatar
0 votes
1 answer
96 views

Set Screensaver Programatically

I have searched for this, but can only find (old) fragments of information.. and nothing especially concrete for Big Sur or Monterey about how to set the screen saver through a script (bash most ...
user avatar
  • 119
3 votes
2 answers
893 views

Convert PS1 prompt from bash to zsh for colour customisation

The macOS Monterey system uses zsh shell instead of bash, and I want to convert this bash command which you'd normally store in a .bash_profile file export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[...
user avatar
  • 61
1 vote
2 answers
278 views

Is there an alternative to whiptail for macOS?

I would like to try out a shell script that makes use of whiptail, but I am on a MAC and whiptail doesn't seem to exist there. Does anyone know if there exists a drop-in alternative (like, for example ...
user avatar
  • 121
9 votes
4 answers
3k views

Mac terminal found open with “man James” text. Have I been hacked?

I found a terminal window open with the below. I ran /bin/bash -x and it looks like VMware was accessed and GPG tools. It also added something suspicious to my login items... have I been hacked?! Also ...
user avatar
1 vote
1 answer
75 views

How to delete line 7 in a file in Bash with sed?

How to delete line 7 in a file in Bash? I tried $ sed -i '7d' ~/demo error:sed: 1: "~/demo": command a expects \ followed by text
user avatar
  • 21

1
2 3 4 5
34