Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1305 votes
31 answers
824k views

Pipe to/from the clipboard in a Bash script

Is it possible to pipe to/from the clipboard in Bash? Whether it is piping to/from a device handle or using an auxiliary application, I can't find anything. For example, if /dev/clip was a device ...
moinudin's user avatar
  • 137k
940 votes
33 answers
892k views

Setting environment variables on OS X

What is the proper way to modify environment variables like PATH in OS X? I've looked on Google a little bit and found three different files to edit: /etc/paths ~/.profile ~/.tcshrc I don't ...
Paul Wicks's user avatar
  • 64.8k
612 votes
6 answers
1.2m views

How to run a shell script on a Unix console or Mac terminal?

I know it, forget it and relearn it again. Time to write it down.
P-A's user avatar
  • 11.1k
584 votes
14 answers
213k views

How to set keyboard shortcuts to jump to beginning/end of line? [closed]

I can see that Ctrl+left/right jumps to the beginning/end of line. How to change this to Cmd+left/right arrow?
chris's user avatar
  • 7,413
471 votes
14 answers
250k views

OS X Bash, 'watch' command

I'm looking for the best way to duplicate the Linux 'watch' command on Mac OS X. I'd like to run a command every few seconds to pattern match on the contents of an output file using 'tail' and 'sed'. ...
joseph.hainline's user avatar
455 votes
15 answers
367k views

sed command with -i option failing on Mac, but works on Linux

I've successfully used the following sed command to search/replace text in Linux: sed -i 's/old_link/new_link/g' * However, when I try it on my Mac OS X, I get: "command c expects \ followed by ...
Yarin's user avatar
  • 180k
361 votes
26 answers
784k views

Installing Homebrew on macOS

According to the Homebrew site, to install it, I need to type: brew install wget I get an error message: -bash: brew: command not found Found this answer. The problem, however, is I don't see brew ...
DBWeinstein's user avatar
  • 9,229
351 votes
6 answers
219k views

Error when using 'sed' with 'find' command on OS X: "invalid command code ."

Being forced to use CVS for a current client and the address changed for the remote repo. The only way I can find to change the remote address in my local code is a recursive search and replace. ...
helion3's user avatar
  • 36.6k
349 votes
14 answers
135k views

Delete node_modules folder recursively from a specified path using command line

I have multiple npm projects saved in a local directory. Now I want to take backup of my projects without the node_modules folder, as it is taking a lot of space and can also be retrieved any time ...
Sumit's user avatar
  • 4,022
287 votes
11 answers
1.1m views

How do I edit $PATH (.bash_profile) on OS X?

I am trying to edit an entry to PATH, as I did something wrong. I am using Mac OS X v10.10.3 (Yosemite) I have tried: touch ~/.bash_profile; open ~/.bash_profile But the file editor opens with ...
Thiago's user avatar
  • 13.2k
270 votes
8 answers
215k views

RE error: illegal byte sequence on Mac OS X

I'm trying to replace a string in a Makefile on Mac OS X for cross-compiling to iOS. The string has embedded double quotes. The command is: sed -i "" 's|"iphoneos-cross","llvm-gcc:-O3|"iphoneos-cross"...
jww's user avatar
  • 101k
270 votes
1 answer
85k views

Git doesn't work on MacOS Catalina: "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing" [duplicate]

After upgrading to MacOS X 10.15 Catalina, I cannot run any git commands in my shell: The default interactive shell is now zsh. To update your account to use zsh, please run chsh -s /bin/zsh. For ...
user avatar
269 votes
16 answers
355k views

How do I create a Bash alias?

I'm on OSX and I need to put something like this, alias blah="/usr/bin/blah" in a config file but I don't know where the config file is.
fancy's user avatar
  • 50.6k
267 votes
10 answers
114k views

`date` command on OS X doesn't have ISO 8601 `-I` option?

In a Bash script, I want to print the current datetime in ISO 8601 format (preferably UTC), and it seems that this should be as simple as date -I: http://ss64.com/bash/date.html But this doesn't ...
Aseem Kishore's user avatar
263 votes
15 answers
549k views

Setting PATH environment variable in OSX permanently

I have read several answers on how to set environment variables on OSX permanently. First, I tried this, How to permanently set $PATH on Linux/Unix but I had an error message saying no such file and ...
patti_jane's user avatar
  • 3,663
248 votes
19 answers
505k views

Why does cURL return error "(23) Failed writing body"?

It works ok as a single tool: curl "someURL" curl -o - "someURL" but it doesn't work in a pipeline: curl "someURL" | tr -d '\n' curl -o - "someURL" | tr -d '\n' it returns: (23) Failed writing ...
static's user avatar
  • 8,286
220 votes
17 answers
112k views

How to make the hardware beep sound in Mac OS X 10.6

I just want that Mac OS X 10.6 does a hardware beep sound like in open suse and other distributions. I tried following approaches Terminal -> beep = -bash: beep: command not found Terminal -> say ...
elhombre's user avatar
  • 2,899
209 votes
12 answers
338k views

List files with certain extensions with ls and grep

I just want to get the files from the current dir and only output .mp4 .mp3 .exe files nothing else. So I thought I could just do this: ls | grep \.mp4$ | grep \.mp3$ | grep \.exe$ But no, as the ...
Mint's user avatar
  • 15.3k
209 votes
7 answers
356k views

How do I make this file.sh executable via double click?

First off I'm using Mac. Next, I need to execute this "file.sh" we will call it. Everytime I need to execute it I have to open Terminal and type: cd /Users/Jacob/Documents/folderWithFileInIt ...
Jacob's user avatar
  • 3,925
185 votes
19 answers
348k views

psql: command not found Mac

I installed PostgreSQL via the graphical install on http://www.postgresql.org/download/macosx/ I see it in my applications and also have the psql terminal in my applications. I need psql to work in ...
user3147424's user avatar
  • 3,492
183 votes
4 answers
62k views

Is there a way to make a link clickable in the OSX Terminal?

I am planning on developing an Mxmlc to Textmate formatter, one that formats mxmlc errors as clickable links, so you can open them up quickly in Textmate as Textmate has a url scheme e.g.: txmt://...
japetheape's user avatar
  • 1,940
182 votes
3 answers
107k views

How to fix Terminal not loading ~/.bashrc on OS X Lion [closed]

Whenever I open a new tab in Terminal using Cmd + T, it opens bash in the same directory, as the previous tab. This works fine when I'm in the ~ directory, but if I'm anywhere else, I get an error ...
Jakub Arnold's user avatar
  • 86.7k
174 votes
3 answers
43k views

How do I capture bash output to the Mac OS X clipboard?

Is it possible to capture bash output to the OS X clipboard?
Stephen Handley's user avatar
161 votes
3 answers
218k views

How to run Gradle from the command line on Mac bash

I have a very simple question. I am brand new to Mac and I am trying to get my Java project moved over to my new Mac. The project has a Gradlew file that I thought I could run from the command line to ...
Barodapride's user avatar
  • 3,633
155 votes
9 answers
160k views

How to Batch Rename Files in a macOS Terminal?

I have a folder with a series of files named: prefix_1234_567.png prefix_abcd_efg.png I'd like to batch remove one underscore and the middle content so the output would be: prefix_567.png ...
kidnim's user avatar
  • 1,547
153 votes
6 answers
207k views

Openssh Private Key to RSA Private Key

(I am using MAC) My id_rsa starts with -----BEGIN OPENSSH PRIVATE KEY----- but I expect it to starts with -----BEGIN RSA PRIVATE KEY----- I have send my id_rsa.pub to server administrator to get the ...
Eleanor's user avatar
  • 2,797
152 votes
6 answers
157k views

How to make zsh run as a login shell on Mac OS X (in iTerm)?

When zsh is set as a login shell on Mac OS X, when it is started by iTerm, zsh doesn't consider that it's being run as a login shell, although it's started as ‘-zsh’ (‘-’ is put as the first character ...
Ivan Tarasov's user avatar
  • 7,298
152 votes
18 answers
133k views

Bash script absolute path with OS X

I am trying to obtain the absolute path to the currently running script on OS X. I saw many replies going for readlink -f $0. However since OS X's readlink is the same as BSD's, it just doesn't ...
The Mighty Rubber Duck's user avatar
151 votes
6 answers
78k views

How do I rename all files to lowercase?

I have for example TREE.wav, ONE.WAV. I want to rename it to tree.wav, one.wav. How do I rename all files to lowercase?
Voloda2's user avatar
  • 12.5k
137 votes
5 answers
323k views

How can I see the current value of my $PATH variable on OS X?

$ $PATH returns: -bash: /usr/local/share/npm/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Library/Frameworks/Python.framework/Versions/Current/...
Karoh's user avatar
  • 2,430
128 votes
13 answers
204k views

Searching your command history on macOS terminal

What is the shortcut to search my command history in macOS terminal? For how long is the history available for searching? Where is it stored?
Aipi's user avatar
  • 2,336
125 votes
8 answers
95k views

How to resolve "You need to have Ruby and Sass installed and in your PATH for this task to work" Warning?

I am in the process of setting up a new Mac for work. I have installed Grunt & Grunt CLI globally. Then I did a npm install inside a project folder to install all dependencies. No problems so ...
Sven's user avatar
  • 13.3k
122 votes
10 answers
390k views

How can I run a C program on Mac OS X using Terminal?

I am new to C. Here is my "Hello, World!" program. #include <stdio.h> int main(void) { printf("Hello, World!\n"); return 0; } After I try to run it using Terminal it ...
Bolat Tleubayev's user avatar
116 votes
11 answers
106k views

How to use GNU sed on Mac OS 10.10+, 'brew install --default-names' no longer supported

Under Mac OS 10.10.3, I installed gnu-sed by typing: brew install gnu-sed --default-names When I type it again, I get the message: gnu-sed-4.2.2 already installed However, even after rebooting the ...
user3781201's user avatar
  • 1,291
111 votes
10 answers
195k views

How to remove entry from $PATH on mac

I was trying to install Sencha Touch SDK tools 2.0.0 but could not run it properly. It created an entry in the $PATH variable. Later I deleted the sencha sdk tools folder but didn't realize that the ...
Tushar Koul's user avatar
  • 2,970
109 votes
4 answers
48k views

How to start a shell without any user configuration?

I need to use a "clean" shell (e.g. bash) under Linux/OSX terminal without any user configuration, but it reads config info from some files (e.g ~/.bashrc) every time it starts. I can modify the file ...
lil's user avatar
  • 2,607
103 votes
11 answers
110k views

How to load ~/.bash_profile when entering bash from within zsh?

I've used bash for two years, and just tried to switch to zsh shell on my OS X via homebrew. And I set my default (login) shell to zsh, and I confirmed it's set properly by seeing that when I launch ...
Blaszard's user avatar
  • 31.7k
101 votes
8 answers
272k views

-bash: export: `=': not a valid identifier

Every time I open my terminal I get the error below: Last login: Sun Aug 4 17:23:05 on ttys000 -bash: export: `=': not a valid identifier -bash: export: `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:...
sunkehappy's user avatar
  • 9,006
100 votes
12 answers
131k views

Gulp command not found after install

I installed gulp(globally) and it looks like it worked because it ran this code: ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├...
iluvpinkerton's user avatar
100 votes
1 answer
31k views

Bash keyboard shortcuts in iTerm like Alt+d and Alt+f [closed]

Everyone at work recommended iTerm2 to me instead of the native Terminal. But iTerm2 doesn't seem to allow me to use bash shortcuts like Alt+B and Alt+F to jump back/forward between tokens, or Alt+D ...
rewolf's user avatar
  • 5,791
100 votes
6 answers
50k views

'+' (one or more occurrences) not working with 'sed' command

I'm trying to refine my code by getting rid of unnecessary white spaces, empty lines, and having parentheses balanced with a space in between them, so: int a = 4; if ((a==4) || (b==5)) ...
Siddhartha's user avatar
  • 4,354
99 votes
11 answers
152k views

Running a command in a new Mac OS X Terminal window

I've been trying to figure out how to run a bash command in a new Max OS X Terminal.app window. As, an example, here's how I would run my command in a new bash process: bash -c "my command here" But ...
Walt D's user avatar
  • 4,631
99 votes
3 answers
105k views

Which shell I am using in mac

Default shell in my mac was bash. I have tried to change it into ZSH by command chsh -s /bin/zsh. Now when I am trying to check the shell type, I am getting different responses. COMMAND-1 input : ...
shantanu's user avatar
  • 1,968
96 votes
2 answers
137k views

What are the differences between using the terminal on a mac vs linux? [closed]

I've been using Ubuntu for the last four years. I have a basic knowledge of shell commands and I prefer working in a terminal rather than using a GUI. Recently I've started using a Mac. I've tried ...
Dileep's user avatar
  • 2,427
88 votes
8 answers
140k views

How to make OS X to read .bash_profile not .profile file

I have read so many suggestions about, not putting your customization aka commands in ".profile" file. Rather, create a .bash_profile for yourself and add your alias and etc. But,when I open the new ...
cherryhitech's user avatar
  • 2,160
88 votes
10 answers
158k views

Open an .html file with default browser using Bash on Mac

So, this is what I need : Let's say I have an index.html file. How do I tell the terminal to open it using the default browser? (Using AppleScript, BASH,...?)
DorBB's user avatar
  • 881
82 votes
7 answers
143k views

Where is the default terminal $PATH located on Mac?

I have been looking throughout the system but I cannot find it. When I do echo $PATH I get the stuff I added, plus the default path. I do not have a .profile, and I do have a .bashrc, but the default ...
Andy's user avatar
  • 10.8k
81 votes
14 answers
111k views

How do I add ~/bin to my path?

I've been having trouble modifying my path to add Sublime Text 2. I've added a ~/bin directory and run this command: ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/...
Graeme's user avatar
  • 1,167
80 votes
5 answers
140k views

Restart terminal without closing on MacOS

How to restart my current MacOS terminal session without closing the window? In Linux I use exec bash but it does not work in this environment. I made a few changes to the .bash_profile (prompt, alias ...
blagus's user avatar
  • 2,275
78 votes
4 answers
39k views

Where do you keep your own scripts on OSX? [closed]

As I write my bash scripts for my OS X that do general things, I am wondering where is a good place to keep them. Is there a directory I can put them all in where they will be picked up automatically? ...
More Than Five's user avatar

1
2 3 4 5
98