Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bash]

The default Unix shell used by Terminal in macOS

0
votes
1answer
17 views

Error when parsing my .bashrc — sytax error: operand expected (error token is “ ”)

I have the following snippet in my .bashrc: # Returns system load as percentage, i.e., '40' rather than '0.40)'. function load() { local SYSLOAD=$(cut -d " " -f1 /proc/loadavg | tr -d '.') # ...
0
votes
1answer
35 views

Calculating sha256 returns also “-bash: <string> command not”

I'm trying to find a SHA256 hash of a string: $ fdsafdsa | shasum -a 256 While it returns a hash, it also throws an error: -bash: fdsafdsa: command not found ...
1
vote
0answers
5 views

What does “Cache location entry for Photos.app in cache file” error signify in Automator app?

I have written a very basic script to count the number of files in a folder, then if it reaches 16 files, to run an automator workflow, as below: #!/bin/bash cd /Users/barbooths/Projects/...
0
votes
2answers
80 views

Copy files from Folder A to Folder B based on Text File C with bash

How do I copy files from Folder A to Folder B based on Text File C with bash? folderA: source folder with image files only, e.g. image01.png, image02.png etc. There are no space in the image names, ...
0
votes
1answer
22 views

Determine com.apple.Finder AppleShowAllFiles status using command line?

Is there a way that I can grab the status of com.apple.Finder AppleShowAllFiles in command line? I switch between AppleShowAllFiles yes & no frequently, I want to write a .command file to check ...
0
votes
1answer
14 views

Hide the cursor from the terminal

I want to be able to hide the cursor programmatically. I am okay with giving any required permissions to the script.
0
votes
1answer
30 views

Script to check to see if certain applications were installed [closed]

I am very new to Macs however I did hear that there was a Bash script that can be utilized to check to see if certain applications were installed on a machine
9
votes
2answers
1k views

Can't run one particular program from Terminal without using its full path

I want to run a program ds9 from the Terminal. The program is clearly in the PATH, which I determined by running: which ds9 /Users/evgenii/miniconda3/envs/iraf/bin/ds9 But when I run the command by ...
0
votes
1answer
19 views

Removing Files after Successful Extraction unrar rm shopt globstar

shopt -s globstar for f in **/*.rar; do dir=`dirname "$f"`; unrar e "$f" "$dir" && rm -frv "${f::-2}*"; done From echoing out testing the rm command, the file is the correct path. I ...
2
votes
0answers
18 views

Change keyboard layout automatically when external keyboard connected

I recently purchased an external keyboard (non-apple) that is used at home and also dragged along with me from time to time, and I've noticed a need. My Mac is in English, as well as its physical ...
0
votes
0answers
17 views

Viewing a terminal script as it runs in Automator

I have written an Automator Service that calls ffmpeg, encodes the selected files in Finder, then sends a notification via Growl to Prowl on iOS. It all works, but I'd like to be able to view the ...
0
votes
1answer
30 views

Command line to create a PDF document from a batch of images [duplicate]

How to create a PDF document from a batch of images ? === Belowis what I tried before posting this question: The ImageMagick way, but the PDF document generated is too big: convert *.ppm book.pdf ...
1
vote
2answers
50 views

Why aren't my profile and bashrc files hidden?

I've been following tutorials to edit .profile, .bashrc and .bash_profile and I discovered that my computer has profile, bashrc and .bash_profile files instead. i.e. Only the .bash_profile file is ...
1
vote
1answer
69 views

In a MacOS Mojave bash script “-w /etc/passwd” is false even for root

An old bash script I have tested to see if a user was root by seeing if /etc/passwd was writeable. In MacOS High Sierra it returned true for root, and false for anyone else. But in macOS Mojave the ...
1
vote
3answers
108 views

Is there any way to convert a bunch of .ogg files in a folder to .mp3 using ffmpeg?

Is there any way to convert a whole heap of .ogg files in about 30 folders in a folder containing those folders to .mp3 files and put them in another folder using the command ffmpeg? The previous ...
1
vote
1answer
115 views

Use 'mv' command to move files except those in a specific directory

In Linux, I know the command mv !(folder1|folder2) folder1 if I want to move all files in current folder, excepted folder1 and folder2, and move they in folder1. But these commend, doesn't work in mac ...
1
vote
2answers
74 views

ls -axi (what does it do)?

So I was messing around in terminal, and when i opened it, I typed cd applications . Nothing bad here. Then, I typed ls -a\ in applications (or maybe /, I don't know, but it opened the > thing ...
2
votes
1answer
37 views

Terminal “ls” command sorting flagged files

ls -lO lists "restricted" flagged files as well as the rest Is it possible to limit the list just to these files and/or to list them sorted first or last in the list?
0
votes
0answers
18 views

Why my local bash script can be opened, but if I download it Apple says it's from an unidentified developer? [duplicate]

I have a bash script that I created myself : myscript. It has execution permissions. When I double-click on it, it opens in the Terminal without issue. But when I zip it (to keep file permissions), ...
0
votes
0answers
6 views

Why a bash script ran directly doesn't need user permissions, but a .app file running the script needs them? [migrated]

I have a bash script myscript that loads some applescript to prompt a graphical interface to the user, to ask for his password. If I run the bash file directly, outside of a .app bundle, it can do ...
1
vote
1answer
20 views

Double-click bash file -> pwd outputs my home directory instead of the current directory [duplicate]

In my Downloads directory, I have an executable bash script : #!/bin/bash pwd when I double-click on it, pwd outputs my home directory. But I want my script to run from the current directory from ...
1
vote
2answers
47 views

Bash_profile doesn’t work

I want use .bash_profile but I have a bug. In my file I have : JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home But When my JAVA_HOME is called by Ionic I have : ...
0
votes
3answers
82 views

How to set relative directory to PATH variable, and run scripts in relative directory globally

I have some some scripts in a git project I wan to access globally, so I add the relative path to the scripts folder like so vim ~/.bash_profile export PATH="~/git/scripts/:$PATH" source ~/....
1
vote
1answer
55 views

Gluing chronologically rtf files via bash script

I like learning and creating small scripts for bash, and now I have finally the first "serious" problem I would like to solve through a script. Here is the situation: I have a folder containing 45 ...
1
vote
0answers
43 views

“sudo chmod 0 /” deployed as script to remote MACs via Landesk

This probably will not make a lot of sense. We have users that have left the company and have not returned their macs. We are using Landesk as main managing platform, however the MAC managing part is ...
2
votes
2answers
97 views

How to run .sh script from usb in Terminal Recovery Mode? [closed]

I am a novice user. I would like to run MacUserGenerator exported shell script to create an account on a brand new iMac without manually doing this in the set up process. Not sure if this possible? ...
1
vote
1answer
131 views

Unexpected -bash command not found error when starting new mac terminal window

I was messing around with ssh keys and permissions and other things I'm not too familiar with and ended up causing some problems on my mac, including denying myself permission to my user account, ...
2
votes
1answer
63 views

How to programatically set Terminal theme/profile

Context for this question: I'm writing a bash script to automatically setup any Mac with my tools/preferences, ideally with one command if possible. The question: I have a .terminal theme file that ...
1
vote
0answers
14 views

Is it possible to create exs24 files with a script?

Say that I have a hundred samples and want to make an exs24 instrument for each of them. Is there any script where I could input some info like name, key and path to the audio file and then have it ...
1
vote
2answers
73 views

Automator: Is it possible to resize an image to a maximum file size?

I have been looking around for an Automator method, whereby an image file is to be resized (reduced height and width) to a specific file size (in bytes), or a near lower-bound proximity of that file ...
0
votes
0answers
13 views

tag program works when invoked directly; errors in find script

I'm using the tag program (https://github.com/jdberry/tag/) to copy tags from images in one directory to the same-named images in another directory. A command that works from the command line is this:...
1
vote
2answers
54 views

Bash Alias Not Found Error

I have the following command that I am trying to put into a bash alias. The command by itself works fine, but when I try to alias it, I am getting the following errors: The Command find . -maxdepth ...
1
vote
0answers
13 views

Automator can't find bash command [duplicate]

I'm trying to make an action on Automator that recursively batch processes PNG images using bash shell script with pngquant I have done this on terminal and got no problem, but now I want to make a ...
2
votes
3answers
127 views

“bash” command runs scripts in version 3.2, not 4.4

Currently, in terminal, my default interactive shell is bash version 4.4. The OS ships with 3.2. If I want to run a script (e.g., my_script.sh) using bash version 4.4, I can source it (source ...
0
votes
1answer
211 views

Automator app stopped working after updating to macOS Mojave

Today I updated to Mojave because the notifications were killing me. A script I have in automator to launch apache server on startup stopped working after the update. This is all this automator app ...
3
votes
2answers
55 views

How do I unmount a drive with a script?

I installed sleepwatcher to run ~/.sleep before my computer goes to sleep. I need to unmount /Volumes/Backup before my computer falls asleep. If I forget to do it, I get a message telling me that I ...
1
vote
1answer
46 views

What's the fish shell equivalent to `set -o vi` to get vi/vim key bindings to access command history and edit?

I'm one of the "cursed ones" that got their start in vi instead of emacs so the shell editing commands I am used to are set in bash with set -o vi but this doesn't work in the fish shell. How can I ...
0
votes
1answer
135 views

How to reset iTerm2 Window/Tab Title when disconnecting from remote host? [duplicate]

I have my bash_profile on my Mac and the remote computers I connect to setup to automatically put the hostname in the window's (or tab's) title area. A bash shell on my local machine A remote host ...
1
vote
1answer
29 views

Dealing with filename extensions - bash vs oascript

I have a script than closes open windows, but it only works when I have enabled the Finder "show all filename extensions" preference. Is there a robust way to accomplish this regardless of the state ...
4
votes
0answers
61 views

Apple's online version function support-sp.apple.com/sp/product?edid= does not work for all macOS versions

I would like to get the Apple marketing name, the code name, for a given version of macOS (e.g. 10.12 is macOS Sierra) from Apple's online service at support-sp.apple.com/sp/product?edid=. This is ...
3
votes
2answers
352 views

Is there a macOS equivalent of the Windows assoc command?

I am looking to change a file association on the Mac using some sort of script. I know that I can do something like that in Windows using the assoc command. Is there something scriptable on macOS ...
1
vote
1answer
58 views

Pass a variable from bash shell into Applescript? [duplicate]

Using the path defined in bash shell How would i pass the variable to applescript using osascript/applescript? Here's what I have so far.. The path of $FOOD_NUM is subject to change and it must be a ...
0
votes
2answers
68 views

How to change the `sh` command to run scripts in bash 4

I have installed bash 4 with Homebred and bash --version shows me the version 4. If I have following test script: #!/usr/local/bin/bash # test-version.sh echo $BASH_VERSION And I make it executable ...
0
votes
0answers
92 views

What's the location of the system-wide bashrc for the brew-installed Bash?

I've installed Bash via homebrew to replace the old pre-installed one. However, the brew-installed Bash doesn't seem to read /etc/bashrc (or /usr/local/etc/bashrc). Where should I put the system-wide ...
2
votes
1answer
29 views

Is there a script for downloading videos from YouTube utilising only Wget or curl on iPhone?

I'm looking for a script that does not utilise youtube-dl and instead Wget or curl (coupled with things like sed and other base UNIX utilities that I wouldn't need to install, like no perl). I'm ...
1
vote
1answer
91 views

Make sourced .bash_profile works immediately in current window [closed]

I use a macOS to connect to an Ubuntu server, after defining new .bash_profile (like upgrading node.js or making new alias), I will have to exit the ssh and login again after sourcing the ....
10
votes
1answer
105 views

Open and focus file browsing dialog from command line

I'd like to open the native file browsing dialog from the command line, focus the dialog, and then get the full path of the selected file. The following works nicely, but the dialog is not focused ...
1
vote
0answers
55 views

How to open multiple iTerm2 tab with admin privilege

So I have an executable program in my /usr/local/bin/ called myApp. I need to run multiple myApp processes in new iTerm2 tabs with sudo. The file structure is like this: --myFolder ----v1 ----v2 ---...
1
vote
1answer
103 views

How do I copy multiple files to macOS's clipboard programmatically?

I ultimately want to have a bash function to-clipboard which gets file paths and copies the files to the clipboard. Using other scripting languages as helpers is okay. I currently have this for ...
0
votes
0answers
42 views

Is there a way to tab-complete Google Drive File Stream top-level folders in Bash?

I'm using Google Drive File Stream on High Sierra. It creates its own folder /Volumes/GoogleDrive with two folders inside this: My Drive and Team Drives. When in terminal and I want to CD to ...