Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
697 votes
16 answers
367k views

How can I clear previous output in Terminal in Mac OS X?

I know the clear command that 'clears' the current screen, but it does this just by printing lots of newlines - the cleared contents just get scrolled up. Is there a way to completely wipe all ...
eonil's user avatar
  • 85.2k
654 votes
10 answers
755k views

OS X: equivalent of Linux's wget

How can I do an HTTP GET from a Un*x shell script on a stock OS X system? (installing third-party software is not an option, for this has to run on a lot of different systems which I don't have ...
SyntaxT3rr0r's user avatar
  • 28.1k
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
540 votes
7 answers
508k views

OS X Terminal Colors [closed]

I just got a Mac after working with Ubuntu Linux for some time. Among the many things I'm trying to figure out is the absence of colors in my terminal window- like the ones that are shown (on Linux) ...
sa125's user avatar
  • 28.7k
288 votes
8 answers
351k views

How to run a shell script in OS X by double-clicking?

I have a shell script that has user execution permission on OS X, but when I double click on it, it opens in a text editor. How can I get it to run by double-clicking it?
c2h2's user avatar
  • 12.2k
276 votes
12 answers
177k views

How to run mvim (MacVim) from Terminal?

I have MacVim installed and I am trying to set it up as the editor for Git (version control), but I can't run 'mvim' from the command line as it isn't recognised. How do I setup mvim so I can run it ...
Fred's user avatar
  • 4,877
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
240 votes
16 answers
130k views

How to send data to local clipboard from a remote SSH session

Most Unix-like systems have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same. On OS X, these commands are pbcopy, pbpaste Is there a way to ...
Alana Storm's user avatar
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
200 votes
2 answers
296k views

Where to place $PATH variable assertions in zsh?

I love zsh, but I am not sure where to place my $PATH and other variable assertions? I find that they are scattered between the files .zshrc .zprofile .bashrc .bash_profile, and sometimes doubled. I ...
stefmikhail's user avatar
  • 7,047
186 votes
12 answers
130k views

Executing Shell Scripts from the OS X Dock?

How do I set up a shell script to execute from the Mac OSX dock? It seems that simply creating a shortcut will open the file in my editor. Is there a flag I need to set somewhere to tell it to run ...
Wilco's user avatar
  • 33.1k
178 votes
14 answers
173k views

Recursive search and replace in text files on Mac and Linux

In the linux shell, the following command will recursively search and replace all instances of 'this' with 'that' (I don't have a Linux shell in front of me, but it should do). find . -name "*.txt" -...
Jack's user avatar
  • 16.6k
157 votes
13 answers
82k views

grep -P no longer works. How can I rewrite my searches?

It looks like the new version of OS X no longer supports grep -P and as such has made some of my scripts stop working, for example: var1=`grep -o -P '(?<=<st:italic>).*(?=</italic>)' ...
kugyousha's user avatar
  • 2,611
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
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
134 votes
8 answers
448k views

Run script on mac prompt "Permission denied"

I'm new to mac with not familiar on terminal command, i put the dvtcolorconvert.rb file on root directory of my volume, this ruby script can converting xcode 3 themes into xcode 4 themes format, which ...
Andy_24's user avatar
  • 1,483
121 votes
7 answers
97k views

How do I set a task to run every so often?

How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X.
stalepretzel's user avatar
  • 15.8k
116 votes
17 answers
95k views

How to copy to system clipboard from tmux output after mouse selection?

Now for copy to system clipboard I have to select via mouse text in tmux window with Shift key. And then I have to run this command: tmux save-buffer - | reattach-to-user-namespace pbcopy Is any ...
tomekfranek's user avatar
  • 6,989
115 votes
9 answers
128k views

How to make a shell script global?

I am on Mac's OS 10.6, and I am trying to learn a thing or two about shell scripting. I understand how to save a shell script and make it executable, but I am wondering what I can do or where I can ...
zebraman's user avatar
  • 2,492
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
108 votes
5 answers
21k views

Easiest way to strip newline character from input string in pasteboard

Hopefully fairly straightforward, to explain the use case when I run the following command (OS X 10.6): $ pwd | pbcopy the pasteboard contains a newline character at the end. I'd like to get rid of ...
Andrew L's user avatar
  • 1,330
106 votes
5 answers
143k views

calling conda source activate from bash script

I'm trying to activate my conda env via a bash script. Even though the script runs fine and my PATH appears to be changed within the script, it's getting reset somehow after the script terminates. I ...
matt_k's user avatar
  • 4,339
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
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
90 votes
1 answer
79k views

How to define array in multiple lines in Shell

Is it possible to define an array in multiple lines in a shell script file? I tried something like this: foo.sh #!/usr/bin/env bash messages=( "Hello" "World" ) echo $messages However, ...
Yuchen's user avatar
  • 32.4k
89 votes
14 answers
222k views

Installing and Running MongoDB on OSX

If someone can provide some insights here I would GREATLY appreciate it. I had a express/node.js app running on MongoDB locally successfully, but upon restarting my computer, I attempted to restart ...
user2517788's user avatar
89 votes
4 answers
31k views

How to delete a word in iTerm in mac os

I am using iTerm as a terminal in my mac. I am not able to delete a word in command line for ex in command cd /path/to/dir, i want to delete just path word , then how can i do that in iTerm. ...
Rohit's user avatar
  • 961
84 votes
8 answers
190k views

How to convert DATE to UNIX TIMESTAMP in shell script on MacOS

On Linux you can convert a date like "2010-10-02" to a unix timestamp in shell script by date -d "2010-10-02" "+%s" Since Mac OS does not have the equivalent -d for date. How do you go about ...
David Young's user avatar
  • 4,713
82 votes
4 answers
49k views

Get wireless SSID through shell script on Mac OS X

Is there any way to get the SSID of the current wireless network through a shell script on Mac OS X?
Mark Szymanski's user avatar
77 votes
10 answers
92k views

How can I batch rename files using the Terminal?

I have a set of files, all of them nnn.MP4.mov. How could I rename them so that it is just nnn.mov?
Jake Wilde's user avatar
74 votes
9 answers
193k views

How to get the PID of a process by giving the process name in Mac OS X ?

I am writing a script to monitor the CPU and MEM of any given process. For that i need to send in the name of the process to be monitored as a commandline argument. For example. ./monitorscript <...
Pradep's user avatar
  • 1,964
74 votes
7 answers
95k views

I get 'Command Not Found' when I try to run Android Emulator on Mac OS X

When I use the Mac OS X Terminal to navigate to the folder with my Android Emulator and type emulator, I get: command not found Here's what happens: $ emulator -bash: emulator: command not found ...
Kebman's user avatar
  • 2,039
73 votes
6 answers
48k views

How to get osx shell script to show colors in echo

I'm trying to add color output to my errors in bash on a Mac. The colors are not working: #!/bin/bash echo -e "\e[1;31m This is red text \e[0m" I see no colors at all, as shown in this ...
nycynik's user avatar
  • 7,511
73 votes
11 answers
164k views

How do you run a script on login in *nix?

I know I once know how to do this but... how do you run a script (bash is OK) on login in unix?
Nate's user avatar
  • 19.3k
70 votes
2 answers
114k views

How to get the last line of a file using cat command

I am writing a shell script in OSX(unix) environment. I have a file called test.properties with the following content: cat test.properties gets the following output: //This file is intended for //...
TheWaterProgrammer's user avatar
60 votes
13 answers
144k views

How to override the path of PHP to use the MAMP path?

After screwing up entirely my PHP configuration on MAC trying to get the SOAP module working (-bash: /usr/bin/php: No such file or directory ....) I now have to use MAMP but each time I have to type ...
sf_tristanb's user avatar
  • 8,815
59 votes
6 answers
66k views

How to kill all processes with the same name using OS X Terminal

Getting the following output from running this: ps aux | grep Python Output: user_name 84487 0.0 0.0 0 0 ?? Z 12:15PM 0:00.00 (Python) user_name 84535 0.0 0.0 0 ...
alphanumeric's user avatar
  • 18.8k
58 votes
7 answers
95k views

Close Terminal window from within shell script (Unix)?

Is there a way to close a Terminal window from within a shell script? I have a .command file that should just get out of the way once it's done.
ericsoco's user avatar
  • 25.9k
52 votes
13 answers
64k views

Bash script, watch folder, execute command

I am trying to create a bash script with 2 parameters: a directory a command. I want to watch the directory parameter for changes: when something has been changed the script should execute the ...
ThomasReggi's user avatar
  • 58.1k
52 votes
1 answer
32k views

"Illegal option" error when using find on macOS

I am trying to list the files only with the letter "R" at the end. I used find as follows in macOS Terminal, find -type f -name '*R' But I got the message saying illegal option --t.
Gravity M's user avatar
  • 1,525
51 votes
8 answers
29k views

How to Open files and folders in same window in Sublime Text on macOS?

If I open ~/foo.txt then open ~/baz/bar.txt from Terminal, Sublime Text always opens 2 different windows. It's aggravating to have all these different windows open.. I've tried changing a bunch of ST'...
corysimmons's user avatar
  • 7,545
51 votes
1 answer
26k views

MAC's "say" command to MP3 [closed]

I want to read a very long text with the SAY mac's command (say -f file.txt), and to record the output to file.mp3. I thought about using ffmpeg to record all of it, but then i'll need to wait for all ...
Oussama L.'s user avatar
  • 1,902
51 votes
6 answers
48k views

Counting number of files in a directory with an OSX terminal command

I'm looking for a specific directory file count that returns a number. I would type it into the terminal and it can give me the specified directory's file count. I've already tried echo find "'...
Milos's user avatar
  • 1,183
50 votes
5 answers
51k views

How to get the default shell

We can run something like chsh -s /usr/local/bin/zsh to set a new default shell. Is there a command we can run to know what that shell is? I don’t mean having a terminal open and running a command to ...
user137369's user avatar
  • 5,564
48 votes
9 answers
57k views

Colored shell script output library

I am looking for a definitive way to build shell scripts that generates colored output. Unfortunately I am having a hard time finding an appropriate lib or good technique for doing this. I found a ...
Bruno Penteado's user avatar
43 votes
8 answers
38k views

Getting a Scala interpreter to work

I'm very new to Scala. I have downloaded it, got it working in Eclipse where I'll be developing it; but I can't make it work in Terminal. All sites and books say to just type scala - this doesn't ...
Alex's user avatar
  • 8,593
43 votes
1 answer
63k views

Make a copy of a file and give it a different name mac terminal

Mac. I'm in a directory dogs/scripts/cats. Within this directory there is a file bla.txt. I would like to make a copy of bla.txt called bla2.txt and keep it in the same directory. How do I do that?...
Doug Fir's user avatar
  • 20.8k
42 votes
3 answers
13k views

Zsh tab-completion for "cd .." [closed]

How can I configure the Zsh tab-completion such that when I type cd ..<TAB> it expands to cd ../ and after pressing <TAB> again proposes the folders in the parent directory for completion? ...
x-way's user avatar
  • 896
42 votes
7 answers
29k views

Is there a way to find the running time of the last executed command in the shell?

Is there a command like time that can display the running time details of the last or past executed commands on the shell?
Behrang Saeedzadeh's user avatar

1
2 3 4 5
50