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 Mac OS X

2
votes
0answers
10 views

iTerm2 - Split vertically with same command history

Is it possible to have same history of commands when I split window vertically in iTerm2 with Command + D as in current window? For example history command shows different list of commands, looks ...
1
vote
2answers
26 views

How can I run an app, when using the full path?

I need to start an app from another app with just one command on macOS. So, I can't use cd to get to the right path. I just need to run the app with the full path like: /my/path/to/app/myapp -...
5
votes
0answers
57 views

Get two-factor authentication code from terminal?

Is it possible to retrieve my Apple ID two-factor authentication code via the terminal instead of the GUI prompt, i.e. via ssh or a bash script? I don't own any Apple devices other than a headless ...
0
votes
2answers
65 views

Running `nano` uses the old nano(2.0.6) even though nano 3.0 is installed

I installed nano 3.0 with brew install nano, but when I run nano --version, it shows version 2.0.6, which is what came with macOS. Screenshot: echo $PATH also shows that /usr/local/bin is listed ...
3
votes
2answers
111 views

Copy the first n files from one directory to another

Im looking to copy the first 'n' files from one directory to another directory preferably with only cli tools (no scripts). I've tried the following: find . -maxdepth 1 -type f | head -5 | ...
0
votes
0answers
21 views

defaults: Writing Nested Directories and Arrays

I'm trying to write a bootstrapping Bash script that will implement the preferences for some of the apps I use, through the defaults write command. There are particular cases that I find the structure ...
5
votes
1answer
97 views

Sort with case-sensitivity (lowercase before uppercase) in macOS in the Terminal

I am trying to use the answer in GNU Sort by case-sensitive to sort a file in my Mac OS. My file.txt looks like this: "Best" "A" "BEST" In the second answer to the mentioned question, it says that ...
0
votes
1answer
16 views

-bash: export: `Drive/Courses/Programming/nand2tetris/tools': not a valid identifier

Every time I log in to the terminal, I get this error. -bash: export: `Drive/Courses/Programming/nand2tetris/tools': not a valid identifier -bash: export: `Drive/Courses/Programming/nand2tetris/tools'...
4
votes
2answers
67 views

Bash - Suppressing output to STDOUT

I've written a script for fresh macOS installs that installs Homebrew, Cask, and a bunch of apps I like, along with creating a .vimrc file. Thanks to an answer by daniel Azuelos (located here: Best ...
3
votes
1answer
95 views

Open Terminal Window with Predefined Environment Variables (Including `PATH`)

I'm trying to create a .command file which will open a terminal window with predefined Environment Variables (Including PATH). I tried this: #!/bin/bash # Adding CMake to Path export PATH=$PATH:/...
0
votes
0answers
34 views

Removing directories from PATH

I am trying to run rkhunter, but it is giving me this output: stack/security/rkhunter-1.4.6 ➜ sudo rkhunter --check Password: Invalid BINDIR configuration option: Invalid directory found: ~/.dotnet/...
1
vote
3answers
600 views

How do I prevented the hackers (secret intel) manipulating my terminal again [closed]

How do I prevented the hackers manipulating my terminal again so that my terminal works correct again? Here in the Netherlands we perform cybertest at the company where we work and the attacks are ...
1
vote
1answer
31 views

Open homebrew version of emacs instead of Apple version

I installed emacs 26.1 via brew install emacs, but when I try to start emacs via command line, only the outdated Apple-supplied version (22.1.1) opens. However, emacs is apparently correctly linked: ...
0
votes
1answer
29 views

Turn on Proxy Without Password Prompt

I am looking for a way to do the equivalent without prompting for password. I need it to be a native way that does not require the user to change any configuration files (including sudoers). And GUI ...
1
vote
1answer
84 views

Endpoint has been activated through legacy launch on Mac Mini

Asking this here as I don't think it's a Linux problem. My Mac Mini sits on a desktop and is the 'central authority' for all of my backups. I have nine Linux virtual machines on a server on which ...
2
votes
2answers
60 views

Zsh vs Bash shell in Terminal

Are there any advantages to using zsh vs bash shell in Terminal app? Also, can you use zsh from the terminal? My understanding of zsh is skewed.
1
vote
1answer
32 views

macOS terminal: quick way to edit command options after bash/zsh autocomplete

The issue I use autocomplete from history a lot whether that's with up-arrow or typing the first few letters and completing the whole command including all arguments (options and others) with right-...
2
votes
1answer
92 views

Why is rename command missing from macOS?

I usually rename files and directories with the mv command. I'm reading a book on bash shell that mentions the rename command. When I executed man rename a man page was shown. However, when I entered ...
3
votes
2answers
38 views

Trigger the Creation of a Specific Preference List?

I have the following function: hardware_model () { local hardware_mod hardware_mod=$(defaults read ~/Library/Preferences/com.apple.SystemProfiler.plist 'CPU Names' \ | cut -sd '"' -f 4 \ | ...
1
vote
0answers
35 views

Terminal Startup command not found

Whenever I open my terminal there is a line that reads, -bash: 6ee67d3f2005ceaf5266c966198b7f3c165bf5d7: command not found This is shown after the line that states my last login information. I am ...
6
votes
2answers
554 views

“bash -D” command doesn't seem to do anything useful

I'm finally getting around to getting more familiar with the shell after all these years. I was exploring the man page for bash and looking at the -D option, which, according to the manual: -D ...
3
votes
1answer
51 views

Unable to resolve hostnames inside macOS chroot jail

I just created a chroot jail with inetutils, coreutils and bash. Most of the things seem to work. I can ping ip addresses and hosts that are inside /etc/hosts, however, I can't ping hosts that are not ...
0
votes
1answer
31 views

Searching forward through bash history

You can hit ctrl-r from the command line to initiate a search for a previously issued command. You can then hit ctrl-r to cycle back through the older commands that match the search string. However, ...
0
votes
1answer
58 views

Bash history not initially remembered with iterm2

I've got an annoying problem with iterm2 not remembering my history when I close out a terminal window. I'm not sure if it might be my .bash_profile config or what. Here is what is happening: 1) ...
2
votes
2answers
70 views

Can't open a PDF from Terminal on Mac because it ‘couldn't get a file descriptor referring to the console’

I tried to use the command: open <filename.pdf> but the message I got was Couldn't get a file descriptor referring to the console What can I do?
3
votes
4answers
123 views

How can I find the “friendly name” of the operating system from the shell / Terminal / bash?

I know that I can use sw_ver to find this information: ProductName: Mac OS X ProductVersion: 10.14 BuildVersion: 18A353d …and I know I can find other things like uname can give me some types of ...
2
votes
2answers
263 views

How to use a pipe in a script optionally

How can I achieve the conditional usage of a pipe for a command execution in a script. It looks like this #!/bin/bash XCPRETTY=" | xcpretty" if [ $(which xcpretty | wc -l) == 0 ]; then XCPRETTY="...
0
votes
1answer
27 views

netsh equivalent command in OSX

How would I construct the bash equivalent of this command? netsh -c interface ipv4 add neighbors "Wi-Fi" "10.0.1.1" "b8:8d:12:57:2d:50" store=persistent Thanks!
0
votes
0answers
23 views

Terminal and iTerm appear to be partially opening in zsh

I recently installed Julia on my iMac running High Sierra. Julia seems to want to run in the Z-shell whereas I normally use bash. I haven't run Julia today but my Term2 windows are screwed up since ...
1
vote
1answer
165 views

Scrolling doesn't work in Terminal for commands like less

I used to be able to scroll using the trackpad through git diff or man pages which both use less when the output doesn't fit on screen. Today I restarted my computer and that behaviour is gone and I ...
1
vote
1answer
77 views

Mac terminal says “-bash: echo: write error: Broken pipe” on opening

I opened my terminal, like I do most days Mon-Fri, and was surprised to see this error: Last login: Fri Jul 27 17:19:25 on console -bash: echo: write error: Broken pipe SomeMac:~ user568458$ ...
1
vote
0answers
26 views

Display emoji faces for correct & wrong commands in terminals

I want to customize my terminal to display emoji faces, showing sad face for wrong command and happy face for right command that I enter. Is there any way that I can do this using my terminal bash. ...
4
votes
2answers
364 views

I have `/usr/bin/env` in my “Macintosh HD” but not in the recovery partition. Is this normal?

I'm working on a MacBook Air, that's currently booting to macOS High Sierra 10.13.6. It also has an Ubuntu 16.04 partition, that I am currently trying to reach. I was trying reinstall rEFInd, which ...
3
votes
1answer
60 views

Embedding AppleScript inside a Bash — getting Error

I'm fiddling with bash for the first time and trying to get something simple to work. #!/bin/bash while true ; do osascript <<EOF tell application "System Events" ...
1
vote
1answer
50 views

NTLM hash function in Terminal?

I'm aware there are a number of hash functions available in terminal such as echo "text" | openssl <hashname> or perl -MDigest::SHA -nle 'print Digest::SHA::sha224_hex($_), ":", $_'. However, I ...
3
votes
0answers
79 views

Bash script detect received iMessage along with its contents?

I've been doing some searching around online for an answer to this question and can't seem to find one. My aim is to run a bash script which waits for the arrival of an iMessage from a specific ...
1
vote
0answers
16 views

Moved /usr/bin and /usr/lib folder, how do I fix it? (iOS 10.2.1, iPhone 6 +)

So long story short, I was trying to free up storage on my root partition, and I made a stupid mistake. I moved my /usr/bin and /usr/lib folder to /var/stash/bin and /var/stash/lib respectively. ...
1
vote
2answers
60 views

plistbuddy command value from csv, search and insert

I have a plistbuddy command that I need to execute for 100 different users. The value I have to enter for the 100 individual users depends on the hostname. I was thinking I could use a csv that has ...
2
votes
0answers
91 views

What are .backup files and how do I remove them?

I'm working on removing hidden files from a directory, but keep running into issues with .backup files. I keep getting permission denied notifications even when using sudo. I'm not sure where they ...
3
votes
1answer
170 views

Add Environment Variable to PATH

I am new to the Apple "eco system" and I am trying to setup my environment variables for local development. Here is what I have in my ~/.bash_profile (simplified for brevity): export PATH="$...
0
votes
2answers
38 views

How to list all /dev/disks, not partitions ending in s1, s2, …?

I am trying to list (output) the drive its Mac OS X name from the serial number in the Bash 3.2 shell on the command line. For this I need to loop through all block devices not being a partition. So I ...
2
votes
2answers
47 views

How do I map a terminal command to a function key?

I have a terminal command that can control my external display's brightness. I'm trying to map that command to a key on the keyboard so it works like a "brightness up" and "brightness down" key. ...
2
votes
1answer
66 views

What the point of custom ANSI colors in Terminal Preferences?

In the preferences of the Terminal App, you can set custom ANSI colors for blue, green, yellow, bright red, etc. but they don't actually change anything in the Shell. For example using ls -G still ...
0
votes
0answers
31 views

Automator: How to create a symbolic link of a folder and adding it to the favorites?

How would you look into a folder and create a symbolic link or shortcut of a folder and add it to favorites ? (bash/shell scripting). Thanks!
3
votes
0answers
46 views

iOS Cannot SIGINT or Ctrl+C when SSH'ed into it

I have a jailbroken iPhone that I often SSH into. For some reason, I am unable to Ctrl+C a foreground process or kill -INT a background process when said process is started in an SSH session, but I ...
2
votes
2answers
84 views

convert an epoch date to human readable

echo "$some_string" | awk -F '|' '{print $1 $2}' $2 is a epoch date and I want to convert it to human readable. I tried doing date -r $2 but no luck. Thanks in advance.
4
votes
1answer
50 views

How to test my installation script on macOS?

What is the best way to test an install script on macOS? I have written an installation script so that others can easily install the program qme-ng which I forked and am working on. However testing ...
0
votes
0answers
17 views

How to schedule or execute install package while computer is sleep? using Apple Remote Desktop

I want to install packages on all our endpoint Apple computers using Apple Remote Desktop. I can't execute scripts or schedule install on the computers that are sleeping. Is it possible to execute ...
2
votes
3answers
161 views

Generic exit function for iTerm2

I've recently begun to use iTerm2 instead of the macOS Terminal application and I'm really happy with it. I'm very used to use to exit command to close the instance that currently has focus. With ...
20
votes
4answers
2k views

.git-completion.bash producing error on macOS Sierra 10.12.6

I've followed the process for git-completion as per the description provided at https://medium.com/@farooqyousuf/autocomplete-git-commands-and-branch-names-in-terminal-on-mac-os-x-4e0beac0388a: The ...