Questions tagged [bash]

The default Unix shell used by Terminal in macOS

Filter by
Sorted by
Tagged with
2
votes
1answer
24 views

How to create recursive download and rename bash script

I need to make a bash script that will download a image with curl and then rename the file, wait 5 mins and then re-download the file and rename it again so that the new file does not replace the old ...
1
vote
1answer
40 views

Why is wc -c printing spaces before the number?

command: echo "test" | wc -c results (7 leading spaces): " 5" I tested this on my linux box and I don't get the space in front of the five. is this a bug or expected behavior?
0
votes
0answers
26 views

Mac OS capture output from shell script that launches application

I have a .Net Core application that I'm running on a Mac. I am currently using a shell script to launch the executable which is working well however I am wondering where the output from the script is ...
1
vote
0answers
25 views

How to pass filename as an argument passed on launch?

I would like to pass the script's filename to the "Arguments Passed On Launch" found in the Scheme editor under "Run". I looked at this Xcode documentation but did not find an answer. Currently, I ...
5
votes
1answer
49 views

Bash: Elegant ways to use multiple variables for shortening long strings?

I am aware of dockutil in homebrew but, I am trying to run a bash script that automatically adds dock icons to the dock on a fresh user account. dockutil has been uncooperative on fresh out of the box ...
2
votes
1answer
19 views

ImageMagick complains when image is missing while stitching together tiles of an image

I have to stitch together pictures (first vertically, then horizontally) with a varying amount of tiles via the command line on macOS 10.14.5. I usually use this command: convert -append 0_0.jpeg 0_1....
1
vote
1answer
24 views

Merge two pdf to one with their pages merged alternatively [duplicate]

I have a PDF A.pdf and B.pdf and would like to merge them both to AB.pdf, where each page is merged alternately so that page 1 in AB.pdf would be the first page of A.pdf and page 2 in AB.pdf would be ...
1
vote
1answer
51 views

Why is my .ssh/config file not readable?

I am trying to edit my ssh/config file, but when I type emacs ~/.ssh/config into Terminal, it says that the file is not readable and will not save my edits. When I try to overwrite, it says permission ...
0
votes
0answers
27 views

'C' Not working within Terminal

I was trying to add functionality to add TAB autocomplete within the terminal and followed this guide. I must have messed up the instructions somehow because now within my terminal the 'c' key does ...
1
vote
1answer
27 views

Command line issues

I'm trying to execute two commands in a single line: pkill "something" && runsomething when executing each command separately, both work. When executed together with "&&", only the ...
-3
votes
0answers
28 views

Automator help: Creating Same Folder name In Multiple folder. And Move Images from a folder to all these newly created folder [closed]

Can you please help me out with this question? I'm trying to create the same folder name to multiple folders. Here I have three parent folders, First one is a root folder, 2nd one is a state name ...
1
vote
1answer
25 views

ignore duplicates when browsing bash history

Assum I have the following command history: A B B When pressing the up arrow on most linux terminals this would cycle like: B A On osx terminal however it got me: B B A How can I regain the ...
20
votes
2answers
6k views

What is this unknown executable on my boot volume? Is it Malicious?

I noticed I had this file in the Macintosh HD folder. And then when I click on it, it shows this: Apparently this file was created in 2017, but I don't remember creating it. Any idea what it could ...
0
votes
0answers
23 views

What is hostname in terminal prompt? [duplicate]

My mac terminal prompt is: wbk-er-10-132-118-162:~ johnjara$ I did echo $PS1 and got \h:\W \u\$, which would be the hostname: the basename of $PWD, my username, respectively. My computer name in ...
2
votes
2answers
47 views

Lost my .bash_profile. Is it possible to recover it from Time Machine backups?

I recently completely reinstalled macOS on my MacBook but I forgot to save my personalised .bash_profile. I was stupid enough not to dump it on Gist for future use, and now I'm looking into restoring ...
0
votes
0answers
36 views

Shell command works fine as is, but not when executed from crontab. What's the difference?

I created a small workflow with the Automator App, and I want it executed periodically. For that I created an entry in crontab. The problem is that running the workflow straight from the Terminal ...
0
votes
0answers
45 views

Bash error using basename

I'm running the Trouton script to change an Mac bound account to a local one but keep getting the error: Expected expression but found unknown token. Tried others syntax fixes but to no avail. ...
2
votes
0answers
28 views

Opening terminal from command line, starting bash and got to the same location where the original terminal was

For example, I have a terminal (running /bin/bash) opened at a certain folder. Now what I want is when I type trm on the terminal, it will open another terminal at the same location where the first ...
0
votes
0answers
32 views

How to set the correct PATH for different software

I installed R via Conda. During the installation Terminal says environment location: /Users/tymac/anaconda3...The following packages will be downloaded:.... Everything was installed but now at bash ...
0
votes
1answer
38 views

How to zip a script-file for MacOS under Windows and give it correct attributes?

I am working under Windows 10 and am putting together a few data-files and a simple bash-script that I want to share with Mac-Users. (I am just learning MacOS, so may have drawn wrong conclusions ...
2
votes
0answers
41 views

Mac Terminal Slow after upgrading to PHP7.3

I had my Mid 2013 macbook air running Mojave (10.14.5) with PHP 7.1.23 updated to PHP 7.3 from https://php-osx.liip.ch/ using the command curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3 . ...
3
votes
0answers
15 views

How to add a terminfo entry systemwide?

I would like to add terminfo entries systemwide for rxvt-unicode and rxvt-unicode-256color. However, when I try to run: HOST:terms alexreinking$ ls rxvt-unicode rxvt-unicode-256color HOST:...
0
votes
0answers
9 views

File permission issue when trying to script command to run via ssh, but can manually ssh and then run command no issues

I am trying to script access to a remote environment variable $CUSTOM_ENV_VARIABLE on my macbook. The following works for me when I do it manually: linux-box:~$ ssh my-macbook my-macbook:~$ env ... ...
0
votes
1answer
24 views

Iterm2 BrokenPipe Failed to exec /usr/bin:/bin:/usr/sbin:/sbin: No such file or directory PATH=/usr/bin:/bin:/usr/sbin:/sbin

Backstory: I've been given a lender computer from the school I'm attending and I was attempting to npm install global packages for my react-native project. I was able to install the packages, but my ...
2
votes
3answers
125 views

find a folder nested in a folder

I need to find a folder nested in a folder. example: /Volumes/"4T Virtual Machines"/outerfolder/innerfolder mac $ pwd /Volumes/4T Virtual Machines mac $ ls -lR outerfolder/ total 0 -rw-r--r-- 1 ...
2
votes
2answers
81 views

Escape space character in pathfile?

I'm trying to set an environment variable for Anki's media folder, in .bash_profile. The line is export ANKI_MEDIA='/Users/<username>/Library/Application Support/Anki2/me/collection.media'. ...
4
votes
1answer
2k views

What does rm -rf $(!!) mean on macOS?

I know rm -rf is a force deletion on everything in a given directory. But I don’t understand what rm -rf $(!!) will do on the command line. How can I look up this syntax or understand what it will do?...
0
votes
0answers
24 views

AppleScript Error sh: /Users/joco/bin/open_file_in_idea: Operation not permitted

I try to execute an one line AppleScript inside OmniGraffle. But I get the following error: AppleScript Error sh: /Users/joco/bin/open_file_in_idea: Operationnot permitted I also attached ...
1
vote
2answers
121 views

Command in bash shell script to find path to that script?

Is there a command to go inside a bash .sh script that will provide the full path to the directory containing that script?
1
vote
1answer
36 views

Including virtual environment in bash prompt

I am using bash on MacBook Air running macOS Mojave and wanted to change the color of terminal prompt. I was helped on this question on SO and this IBM blog after which I used export PS1="\[\e[...
0
votes
0answers
40 views

Applescript to set environment variable before opening terminal

I have the following Applescript in a workflow assigned to a service hotkey that opens a terminal in a given Finder window: tell application "Finder" set myWin to window 1 set thePath to (...
1
vote
1answer
97 views

Large .bash_profile increasing time for terminal to do things. Able to fix?

I've got an almost 100 line .bash_profile which does things like check the git branch and colour certain text. This makes things like even starting a new line significantly slower compared to the ...
0
votes
0answers
23 views

osa script to get user input with if condition

I want to run osa script to run in self-service application. first this line needs to be displayed: osascript 'tell app "System Events" to display dialog "Save and close all your files and ...
0
votes
1answer
20 views

Allow Shell Script to Access Protected Library Folders (launchd)

I'm trying a bash script that works fine when run from the command line (Terminal). Apart from the shebang, it just has: ls -alt /Users/<username>/Libary/Mail/V6/.../Lists.mbox (Using ls as a ...
0
votes
1answer
52 views

No Prompt & Password Fill Install for Homebrew

I'm trying to create a script to deploy macOS and the last piece that isn't automated is installing Homebrew. Because of the unique scenario where Homebrew shouldn't be installed with sudo, and it ...
0
votes
0answers
59 views

.command The file could not be executed because you do not have appropriate access privileges

I am trying to execute a terminal command by just double clicking a .command file. But I am getting this error. The file “myfile.command” could not be executed because you do not have appropriate ...
0
votes
3answers
69 views

macOS Catalina still uses bash as the default shell

I'm on the latest public beta of macOS Catalina and it's supposed to use zsh as the default shell and it even shows that it is pointing to zsh in the users settings but whenever I open a new terminal ...
0
votes
1answer
55 views

How can I prevent line numbers from appearing in .bash_history?

Recently, line numbers have started to appear in my .bash_history file. Where before, for example I might have had just rm -rf * I now have entries like #1565909296 rm -rf * How do I prevent those ...
3
votes
6answers
200 views

Is it possible to script what applications should open certain file extensions?

I have a new Macbook Pro and I'm reminded that my development environment isn't tailored to what I setup on my previous Macbook. I was curious if it's possible to create a script in either AppleScript ...
1
vote
2answers
286 views

How to execute python script by terminal?

I wanted to learn Python, I installed some software. I created a little execution files and none of them will execute. So I've checked my terminal and type basic things like Is, cd etc. None of them ...
0
votes
2answers
55 views

How do I write folder-agnostic shell script on Mac as I can do in Windows?

I would like to write a set of shell scripts which would execute smoothly on Mac disregarding where they are called from. I am currently struggling about how to implement this. On windows, I could ...
3
votes
1answer
44 views

Bash script combine echo say and read

Using a bash script on Mac OS X, how do I combine echo, say and read to make it cleaner and less line of code? The below script works but to me there are too many lines. Thanks a lot for your help. ...
1
vote
1answer
23 views

working with lf x0A in bash terminal

I'm mystified why the variable $lf isn't printing out when using hexdump -C This is a copy with comments added from a run in macOS 10.10.5 bash terminal. mac $ lf=$(echo -ne "\x0a") # What ...
2
votes
1answer
118 views

Where can I see modifications made to the PATH environment variable by the Go installer

I've identified several changes to the PATH variable in Bash that aren't listed in e.g. /etc/profile, ~/.profile, .bash_profile, ~/.bashrc. The following snippet from the Go installation page ...
2
votes
2answers
79 views

OS X - build a bash function to send notifications via osascript / Applescript

Hoping some one can point out what I am doing wrong. After looking through several threads, plus lots of experimentation, it feels like something simple is wrong. The threads I read include How can I ...
2
votes
1answer
77 views

Bash doesn't support `show-mode-in-prompt` readline option for `vi` editing-mode on macOS?

I've played with vi command-line editing in Bash on Linux, and wanted to enable in macOS too, but while vi editing seems to be supported, I cannot get Bash to display vi's mode on the command-line ...
1
vote
1answer
40 views

Cannot `brew install` from a `bash` script

I want to create a script to setup an environment on a Mac. Here's a simple sample... #!/bin/bash brew install gcovr || exit 1 gcovr --version NOTE: Script assumes brew was previously installed . ...
1
vote
0answers
93 views

Where is system default environment variable set in MAC OS? [duplicate]

I am using macOS High Sierra V10.13.6. I can set up my custom environment variables in .bash_profile. But where is the system default environment variables are stored in the mac system For Ex: If i ...
3
votes
3answers
126 views

Mac OS X - Bash script if statement based on system status

Creating a bash script and using the if statement, how do I execute a command based on a system status? if a specific system status is enabled do something, else do something different? I give you a ...
0
votes
2answers
68 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. I do sudo bash, but I'm getting lots of errors in my ....