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
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
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
420 votes
18 answers
411k views

View tabular file such as CSV from command line [closed]

Anyone know of a command-line CSV viewer for Linux/OS X? I'm thinking of something like less but that spaces out the columns in a more readable way. (I'd be fine with opening it with OpenOffice Calc ...
Benjamin Oakes's user avatar
411 votes
21 answers
362k views

Is there a way to make mv create the directory to be moved to if it doesn't exist?

So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would ...
Paul Wicks's user avatar
  • 64.8k
344 votes
14 answers
119k views

sed in-place flag that works both on Mac (BSD) and Linux [closed]

Is there an invocation of sed todo in-place editing without backups that works both on Linux and Mac? While the BSD sed shipped with OS X seems to need sed -i '' …, the GNU sed Linux distributions ...
dnadlinger's user avatar
  • 6,071
342 votes
12 answers
511k views

What languages are Windows, Mac OS X and Linux written in?

I was just wondering who knows what programming languages Windows, Mac OS X and Linux are made up from and what languages are used for each part of the OS (ie: Kernel, plug-in architecture, GUI ...
Brock Woolf's user avatar
  • 47.1k
276 votes
6 answers
397k views

How would I get a cron job to run every 30 minutes?

I'm looking to add a crontab entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but it doesn't seem to run on 0. */30 * * * ...
Darryl Hein's user avatar
254 votes
22 answers
277k views

How can I use xargs to copy files that have spaces and quotes in their names?

I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together find and grep with xargs, I get the ...
Drew Stephens's user avatar
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
238 votes
16 answers
143k views

Finding current executable's path without /proc/self/exe

It seems to me that Linux has it easy with /proc/self/exe. But I'd like to know if there is a convenient way to find the current application's directory in C/C++ with cross-platform interfaces. I've ...
Uros Dimitrijevic's user avatar
236 votes
7 answers
79k views

Linux equivalent of the Mac OS X "open" command [closed]

I've found the "open" command in Mac OS X very handy in the command line. From "man open": The open command opens a file (or a directory or URL), just as if you had double-clicked the file's ...
user avatar
230 votes
6 answers
215k views

Delete .DS_STORE files in current folder and all subfolders from command line on Mac [duplicate]

I understand I can use find . -name ".DS_Store" to find all the .DS_Store files in the current folder and all subfolders. But how could I delete them from command line simultaneously? I found it's ...
SixSigma's user avatar
  • 3,060
219 votes
1 answer
151k views

SSH Port forwarding in a ~/.ssh/config file? [closed]

So I typically run this command a lot: ssh -L 5901:[email protected]:5901 I use it to do VNC over SSH. How do I convert that command into something that will work in a ~/.ssh/config ...
Snow_Mac's user avatar
  • 5,777
184 votes
4 answers
135k views

sed command with -i option (in-place editing) works fine on Ubuntu but not Mac [duplicate]

I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX: sed -i "/ $domain .*#drupalpro/d" /etc/hosts I'm getting: sed: 1: "/etc/hosts": extra characters at ...
Michelle Williamson's user avatar
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
166 votes
9 answers
146k views

Why Maven uses JDK 1.6 but my java -version is 1.7

I have setup maven in my terminal, and when getting the version settings (using mvn -v) it seems it uses JDK 1.6, while I have JDK 1.7 installed. Is there anything wrong? The commands I enter are ...
Ninja's user avatar
  • 2,529
123 votes
4 answers
9k views

Why does rand() repeat numbers far more often on Linux than Mac?

I was implementing a hashmap in C as part of a project I'm working on and using random inserts to test it. I noticed that rand() on Linux seems to repeat numbers far more often than on Mac. RAND_MAX ...
Theron S's user avatar
  • 1,353
116 votes
2 answers
87k views

Should I use libc++ or libstdc++? [closed]

I am developing command line interface executables for both osx and linux using c/c++. The project will link against opencv. Should I use libc++ or libstdc++?
MobileDev's user avatar
  • 3,775
113 votes
6 answers
258k views

"pkg-config script could not be found" on OSX

I am trying to install some software on my mac; however I keep receiving the same error: configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set ...
Shinobii's user avatar
  • 2,511
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
100 votes
14 answers
353k views

How to check all versions of Python installed on OS X and CentOS

I just started setting up a CentOS server today and noticed that the default version of Python on CentOS is set to 2.6.6. I want to use Python 2.7 instead. I googled around and found that 2.6.6 is ...
hch's user avatar
  • 6,280
88 votes
5 answers
46k views

Is Mac OS X a POSIX OS?

What is it that makes an OS a POSIX system? All versions of Linux are POSIX, right? What about Mac OS X?
node ninja's user avatar
  • 32.7k
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
84 votes
3 answers
64k views

How does Docker run a Linux kernel under macOS host?

I installed Docker on my macOS Sierra as follows. Note I don't have VirtualBox installed. brew cask uninstall virtualbox brew cask install docker My macOS details. $ uname -a Darwin m-C02QG7TRG8WN....
Lone Learner's user avatar
  • 19.8k
77 votes
12 answers
49k views

Cross-platform space remaining on volume using python

I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is ...
user avatar
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
7 answers
158k views

id_rsa.pub file SSH Error: invalid format

My co worker and I have been trying to get my macbook to ssh into our AWS production server with no luck, this did work several months ago, but when we went to do it yesterday - we kept getting the ...
ochero's user avatar
  • 857
65 votes
2 answers
53k views

nvm: Cannot uninstall currently-active node version

I am doing this on OSX. I need to delete node. but after I type cmd: nvm uninstall v4.4.7 it prompts me that nvm: Cannot uninstall currently-active node version v4.4.7 How can I uninstall node ...
Henry's user avatar
  • 3,090
65 votes
12 answers
111k views

Linux USB: turning the power on and off?

How can I programmatically enable and disable the power to a particular USB port on Linux? Is such a thing even possible? Mac answers appreciated as well! I was trying for a BOC (don't pretend you ...
Mark Harrison's user avatar
64 votes
4 answers
34k views

Discovery of Dynamic library dependency on Mac OS & Linux

On Windows there is a tool Depends.exe to discover dependency of an EXE/DLL file on other DDLs. Which commandline tool is equivalent on Mac OS and Linux?
Viet's user avatar
  • 18.2k
64 votes
10 answers
83k views

A way to determine a process's "real" memory usage, i.e. private dirty RSS?

Tools like 'ps' and 'top' report various kinds of memory usages, such as the VM size and the Resident Set Size. However, none of those are the "real" memory usage: Program code is shared between ...
Hongli's user avatar
  • 18.8k
63 votes
1 answer
3k views

Weak symbol aliases on OS X similar to those on Linux, or a closest equivalent?

What I do When writing shared libraries for Linux, I tend to pay attention to relocations, symbol visibility, GOT/PLT etc. When applicable, I am trying to avoid calling PLT stubs when functions from ...
user avatar
62 votes
1 answer
20k views

Does OS X have an equivalent to /dev/shm?

Does OS X (Snow Leopard in particular) have an equivalent to (some versions of) Linux's /dev/shm , ie something where you can write to and read from a file without necessarily touching the hard drive?
Andrew Grimm's user avatar
  • 80.4k
60 votes
4 answers
107k views

How to download a file into a directory using curl or wget? [closed]

I know I can use the following 2 commands to download a file: curl -O example.com/file.zip wget example.com/file.zip But I want them to go into a specific directory. So I can do the following: curl ...
at.'s user avatar
  • 52.1k
57 votes
7 answers
51k views

Installing rgl on Ubuntu and Mac: X11 not found

I have seen this question here: Error in loading rgl package with Mac OS X but there is no mentioning about installation error, which is my case. I cannot install rgl package, using this command in R: ...
Matin Kh's user avatar
  • 5,178
56 votes
3 answers
24k views

What's the difference between "env" and "set" (on Mac OS X or Linux)? [closed]

I get similar results running "env" and "set". Set gives more results - is it a superset of env? The man page for set doesn't give any information. How do these commands work and what's the ...
stupakov's user avatar
  • 1,455
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
8 answers
80k views

How can I define a bash alias as a sequence of multiple commands? [duplicate]

I know how to configure aliases in bash, but is there a way to configure an alias for a sequence of commands? I.e say I want one command to change to a particular directory, then run another command. ...
stormist's user avatar
  • 5,845
49 votes
3 answers
64k views

ldconfig equivalent in Mac OS X?

Is there a parallel command to Linux's LDCONFIG for Mac OS X's Terminal?
Tomer Lichtash's user avatar
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
48 votes
13 answers
60k views

Command line Arduino compiling and uploading?

How do I compile and upload Arduino sketches from the command line on Mac and Linux? I've installed the Arduino programming environment. Are there some sample makefiles anywhere?
Mark Harrison's user avatar
48 votes
8 answers
83k views

How do you do non-blocking console I/O on Linux in C?

How do you do nonblocking console IO on Linux/OS X in C?
nonpolynomial237's user avatar
46 votes
7 answers
95k views

No package 'libxml-2.0' found

I am trying to add libvisio in my mac os x from https://wiki.documentfoundation.org/DLP/Libraries/libvisio I have added all dependancy described there listed bellow: boost gperf icu librevenge ...
Rohan's user avatar
  • 708
46 votes
5 answers
33k views

sed: -i may not be used with stdin on Mac OS X

I am using a bison parser in my project. When I run the following command: sed -i y.tab.c -e "s/ __attribute__ ((__unused__))$/# ifndef __cplusplus\n __attribute__ ((__unused__));\n# endif/" I get ...
sarghau's user avatar
  • 562
45 votes
18 answers
43k views

Keep Remote Directory Up-to-date

I absolutely love the Keep Remote Directory Up-to-date feature in Winscp. Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can theoretically be ...
Jake McGraw's user avatar
45 votes
3 answers
67k views

What is the difference between xterm-color & xterm-256color?

I've come across both xterm-color and xterm-256color as options when trying to set up my terminal program to use color - i.e. you can set your TERM environment variable to either one. I was ...
user12345's user avatar
  • 3,076
44 votes
5 answers
66k views

connecting to amazon aws linux server by ssh on mac

I created a new keypair and downloaded it to my mac, then set up a new Amazon Linux AMI server with that keypair and my security group. Now I need to put the keypair .pem file that I downloaded in a ....
brno792's user avatar
  • 6,729
43 votes
4 answers
42k views

Macros for GCC/G++ to differentiate Linux and Mac OSX?

Macros for GCC/G++ to differentiate Linux and Mac OSX?
Viet's user avatar
  • 18.2k
42 votes
6 answers
62k views

How to obtain MAC address of WiFi network interface?

It seems the java.net.NetworkInterface implementation of android does not have a byte[] getHardwareAddress() method http://developer.android.com/reference/java/net/NetworkInterface.html I've found ...
Gubatron's user avatar
  • 6,349

1
2 3 4 5
55