Questions tagged [bash]

The default Unix shell used by Terminal in macOS

Filter by
Sorted by
Tagged with
0
votes
1answer
11 views

lots of errors after sudo bash in terminal

I want to run lots of terminal commands without having to place sudo in front of every command. I am running in macOS 10.10.5 in terminal. Here was the problem: I had saved the file as a windows ...
0
votes
0answers
14 views

What could make the colors in the terminal turn black?

There is a common phenomenon both in VimR and in Vscode, in which any colorful text in the terminal appears in black. https://github.com/qvacua/vimr/issues/728 https://github.com/Microsoft/vscode/...
2
votes
2answers
53 views

How to change the password of a local admin user that has never being logged in using a bash script

Every Mac OS X system in my company uses 3 local users accounts. 1st user is a local administrator user, the 2nd user is a local standard user and the 3rd user is a local administrator user. The 3rd ...
1
vote
1answer
45 views

bash command works on Ubuntu but not on macOS

I have this command which works fine on Ubuntu but on macOS I get an error. The command: sudo $(grep -qxF '127.0.0.1 app.local' /etc/hosts || echo '127.0.0.1 app.local' >> /etc/...
6
votes
2answers
164 views

extract the top-level domain and the second-level domain from a URL

I'd like to extra the top-level domain and the second-level domain from a URL like "https://apple.stackexchange.com/questions/ask" Example URL with desired result below. https://apple.stackexchange....
1
vote
1answer
29 views

Tried to use bash arrays but for some reason this fails?

Im trying to make a script that should be executed with crontab, but I'm having difficulties to declare an array an fetch the key and value from that array. (Running MacOS 10.12.6) This is what i'v ...
0
votes
0answers
32 views

Comparing Directory Structures recursively in bash

I'd like to recursively compare two directories in bash using something I can put into an if ![ x=y ] type test. The directories are intended to have a synchronisation between them using rsync which ...
1
vote
0answers
22 views

How to paste files using Applescript (or bash)?

I want to paste a file copied by Finder in the terminal. Sth like pbpaste but for binaries. (pbpaste itself just returns the basename of the copied file.)
1
vote
1answer
35 views

How can I stop AppleScript from converting variables like “\087” into their octal form when passing through bash?

I have a program I'm using to write xml with variables, and it passes through AppleScript and bash to form the final xml. However, one of my variables usually begins with "024", "054", or other three ...
0
votes
1answer
19 views

I have override a file in bin folder and this affect other programs

I was installing phpstorm. It use shortcut to use it in bin files as "ps" to use "ps" in terminal to open phpstorm. I didn't know that a file with that name already existed, and I found that when I ...
3
votes
2answers
95 views

Help to replace a blank space with a backslash and blankspace in a variable in Run Shell Command with Automator

Im creating an automator service that transcodes all the files within a folder to a compressor preset by running the following shell script: VAR="/Applications/Compressor.app/Contents/MacOS/...
9
votes
2answers
441 views

Change the default text editor in Terminal

I just discovered that Control + X + E opens a text editor in the Terminal that allows me to edit the most recent command before executing it again (I think it is actually a bash thing). However, the ...
0
votes
1answer
90 views

How to apply a bash script just to one user account?

Generally speaking I manage my MAC OS X High Sierra and Mojave systems using very basic script(s) that I remotely send and apply to the entire Mac OS X system, that means all these script(s) are ...
4
votes
1answer
97 views

Search folder, copy to new folder and change names of the files!

So I'm trying to recursively search folder, and as you might imagine it will be the "Photos"-folder in MacOS. And in the process, I would like to change the file name, why you might ask? Because ...
0
votes
1answer
45 views

Escape every character in bash

I want to take a string like this: Example string 59^!#&$( And turn it into this: \E\x\a\m\p\l\e\ \s\t\r\i\n\g\ \5\9\^\!\#\&\$\( I've tried: sed -e 's/./\\&/g; 1{$s/^$/""/}; 1!s/^/"/; ...
-1
votes
1answer
88 views

Bash Shell Prompt change color when in root mode

Mac OS X, how do I set the bash shell prompt (PS1) that every time the user type sudo su (root mode) the shell prompt change from the standard color to the red color and of course if the user exit ...
0
votes
0answers
13 views

Sound in Ubuntu not in Mac OS

I broke the headphone jack. Internal speakers disabled in Mac OS. However when installing Ubuntu the speakers work normally. Can I somehow install the Ubuntu drivers into Mac Os or something? to make ...
0
votes
0answers
41 views

How to delete pre-installed apps on macOS Catalina [duplicate]

I used csrutil disable to turn off System Integrity Protection and deleted some unused pre-installed apps before macOS 10.14. Recently, I upgraded to macOS 10.15 Beta (19A487l) and found this way didn'...
1
vote
3answers
156 views

Move folders using Terminal by referencing a CSV file

I have a CSV file containing the following two columns: Column A: From Directory (e.g. /Volumes/Backup Plus/Salesforce/Order Test/OR-1000049439). Column B: To Directory (e.g. /Volumes/Backup Plus/...
1
vote
1answer
141 views

Make Homebrew installed Vim override system installed one

I have troubling merging several version of vim on my machine. I have successfully installed vim via Homebrew. Here's the output of running brew info vim: vim: stable 8.1.1550 (bottled), HEAD Vi '...
3
votes
0answers
54 views

How can I detect which button was clicked in the DMG EULA confirmation screen

I'm using the open command to automate (via bash) opening a dmg which has a EULA attached to it. When I run open my_app_distribution.dmg I get a screen that looks like this: The open commands uses ...
1
vote
1answer
104 views

cp command: Overwrite confirmation with file diff

When running cp command to copy files, I would like to be prompted for overwrite confirmation, and, if possible, view the file diff confirming. Is this possible? And if yes, how? Ideal example: $ ...
0
votes
1answer
76 views

What modifies the PATH variable on macOS? [duplicate]

echo $PATH returns a different result than the PATH variable I define in .bashrc. .profile is empty. What else could be modifying the PATHvariable? The directories listed are all things I would have ...
0
votes
0answers
32 views

Distribute bash script 'silently' to multiple macos machines

We want to deploy a script 'silently' across all mac machines in organization. We have created a bash script that will run using launchd agent. We need to deploy the launchd agent and script on all ...
1
vote
1answer
21 views

Get french accent on Linux terminal connected via ssh from MacOS High Sierra

I come on this forum since no answers or suggestions on other forums. I am often connecting from a MacOS High Sierra terminal via SSH to a Debian 8.0. The locales on my MacOS are : LANG= LC_COLLATE="...
1
vote
1answer
31 views

Bash History missing from Terminal

After an OS update, my bash history is suddenly gone - typing "history" at a terminal window (sudo or standard) yields only the commands entered after the upgrade. What could have happened here?
0
votes
1answer
46 views

Prevent Terminal from overwriting preferences on exit

When a user loads my C++ program, I want Terminal to look a certain way. I solved this by wrapping my program in an AppleScript .app which overwrites ~/Library/Preferences/com.apple.Terminal.plist (...
2
votes
1answer
37 views

How to find the PID(s) of a hung app in macOS from the shell (Terminal)?

Within Activity Monitor.app it's easy to visually identify a hung app by seeing its name in red text: How can such hung app statuses be identified from the shell (Terminal.app) and the PID(s) of ...
1
vote
2answers
35 views

Launch of terminal after system login takes around 60 sec, is there a way to speed it up?

Here is my .bash_profile export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "...
1
vote
1answer
37 views

how to reset $SHELL variables in root from user space

I've switched my bash to zsh in root using chsh -s /usr/bin/zsh root After when I change back to bash, I type the wrong path: chsh -s /usr/bin/bash root Now I cannot enter root and I get this ...
2
votes
2answers
66 views

Change output format of “top” command in Mac OS for memory usage?

I am using the top command in Mac OS from this answer to grab memory usage: $ top -l 1 -s 0 | grep PhysMem PhysMem: 5490M used (2569M wired), 11G unused. Can I go from that to possibly printing out ...
45
votes
3answers
4k views

What are the practical differences between Bash and Zsh?

With the news that Catalina will default to Zsh instead of Bash, I'm finding lots of results telling me about the switch, and that it may cause problems with shell scripts, but I'm not familiar enough ...
0
votes
0answers
13 views

Why does my terminal on a Macbook Pro say Thomass-Iphone? [duplicate]

My name is not Thomass nor do I know one however I have this going on in my terminal, how can I fix this?
3
votes
3answers
304 views

Remove sudoers using script

At the moment I'm working on a solution to prevent all admins users (except one particular) from running sudo. I can add a specific user to sudoers by running: sudo -i echo '$username ALL=(ALL:ALL) ...
0
votes
0answers
25 views

How to associate file extension with executable using bash?

In my bash script setup.sh, how to make macOS associate .foo extension with /usr/local/bin/bar, so that I can click on X.foo in Finder (say) and have macOS perform /usr/local/bin/bar X.foo?
4
votes
3answers
326 views

Can't connect to Internet in bash using Mac OS

My browser works perfectly using the using Internet, however, when I tried to use this command in bash: ping -q -w1 -c1 google.com &>/dev/null && echo online || echo offline It gives ...
0
votes
0answers
22 views

Bash prompt customization not working

I have installed Git Aware Prompt. I have followed the instructions in the project readme file and customised my prompt in ~./bash_profile by adding the following lines: export GITAWAREPROMPT=~/.bash/...
0
votes
0answers
19 views

Forward deleting (Macports/bash): Is there an alternative to Fn+Delete and Control+D?

As a more general version to this question, is there a way to forward-delete in a bash terminal that doesn't involve Fn+Delete or Control+D? Motivation: When using the Macports port command ...
0
votes
1answer
29 views

How to forward delete in Macports?

When using the interactive Macports shell (running port), is there a way to delete characters to the right of the cursor? Normally, you can simply use key the combination Fn + Delete to forward-...
0
votes
0answers
19 views

Mac OS terminal tab separate histories

Terminal gets bash to go through and elaborate dance to keep separate histories for each tab. Normally (for me anyway) after a restart of Mac OS these separate histories are lost and you are left ...
0
votes
1answer
59 views

Why isn't a binary not being found in my PATH?

I've got a Python project which uses a virtual environment. In my project folder, there is a bin/ folder which contains all the executables needed by the project. To use these, you run source bin/...
0
votes
2answers
146 views

Connect and run commands over SSH using script

I'm using a series of commands for deploying my files to production. This is currently done manually. Is it possible to make these commands into an executable file? So that I don't have to copy paste ...
0
votes
1answer
21 views

Can't store multiple arguments with read -p in macOS terminal using bash

I am trying to store words from an input as parameters with read -p as follows : read -p "Enter your command: " cmd arg1 arg2 echo "$cmd" echo "$arg1" echo "$arg2" With this, $cmd ...
0
votes
1answer
58 views

The command for alias local='…' gets run on terminal open

I have an alias set up in my .bash_profile file: alias local='npm run start-local', and for whatever reason when I open a new terminal session it is trying to run that command npm run start-local ...
0
votes
1answer
22 views

Disable bash command completion (bash v. 5.0.7(1))?

I'm trying to remove all tab completion features from my shell to start over and rebuild it properly. I have homebrew installed and it's running bash v. 5.0.7(1). I had the bash-competion brew ...
0
votes
1answer
9 views

“type” and “which” programs coming up empty for programs on the path

Here is an example of a program that is in the path, find-able by tab / command-completion and accessible but not found by which: kafka- However running which kafka or type kafka comes up empty ...
0
votes
1answer
37 views

Retrieve folder's name for Automator's shell script action

For the sake of concatenating video files, I've assembled bits of code found online into a ffmpeg bash script on Automator. It works. However, I'd like for the output file to be named after the folder ...
2
votes
1answer
167 views

MacBook Pro stuck on GRUB minimal Bash at startup

I had a dual boot Linux Mint 19 and macOS on my MacBookPro11,2. Since the CPU was overheating with Linux, I decided today to delete the Linux partition. Little problem, when I start my MacBook Pro now,...
2
votes
0answers
175 views

Create User via Terminal with Bash in macOS Mojave

In general, you can create a user via Terminal in macOS using Apple's documented method. However, macOS Mojave introduced various security mechanisms that cause scripts to fail when changing user ...
1
vote
1answer
34 views

Running Compiled AppleScript from DMG Doesn't Work

As a follow up for my previous question (Set the Working Folder of .app Created by Apple Script) I have the following problem. I have an AppleScript which is Poor man's Installer: tell me to ...