Hot answers tagged

60 votes
Accepted

Why did {} start appearing as äå in Terminal.app?

I can reproduce it with the xterm terminal emulator (version 366), if I do: $ printf '\e[?42h\e(H'; cat chars.txt; printf '\e(B\e[?42l' !É#$%Ü&*()_+äå Where: \e[?42h. Enables National ...
user avatar
59 votes
Accepted

GZip doesn't produce the same compressed result on macOS vs Linux

Note that the compression algorithm (Deflate) in GZip is not strictly bijective. To elaborate: For some data, there's more than one possible compressed output depending on the algorithmic ...
user avatar
  • 636
34 votes

How to fix "VirtualBox VM quit unexpectedly" when running my Ubuntu 20.04 LTS VM on MacOS Catalina 10.15 in VirtualBox?

Go to Settings > Audio and uncheck "Enable Audio". There seems to be a bug that crashes Ubuntu 20.04 LTS in VirtualBox when it attempts to check audio input permissions with CoreAudio. 00:...
user avatar
  • 441
31 votes

How do I delete a directory that contains only '.' and '..', but rm says is not empty?

Your directory looks empty, but the ls output indicates that there is a file in there since the link count for the directory is 3 rather than 2 (an empty directory on an APFS filesystem should have a ...
user avatar
  • 267k
31 votes

ssh connection "client_loop: send disconnect: Broken pipe" or "Connection reset by <IP> port 22"

I solved the same problem by editing the file ~/.ssh/config to have: Host * ServerAliveInterval 20 TCPKeepAlive no Motivation: TCPKeepAlive no means "do not send keepalive messages to ...
user avatar
28 votes

Why can't I pipe `pwd` to `open` on macOS?

The open utility on macOS does not read from standard input, but take its arguments from the command line. To open the current working directory, you would have to say $ open "$( pwd )" or $ open "...
user avatar
  • 267k
22 votes
Accepted

How to move directory into a directory with the same name?

To safely create a temporary directory in the current directory, with a name that is not already taken, you can use mktemp -d like so: tmpdir=$(mktemp -d "$PWD"/tmp.XXXXXXXX) # using ./tmp.XXXXXXXX ...
user avatar
  • 267k
21 votes
Accepted

Remove files without string in name

Using an extended globbing pattern in bash: rm ./!(*999*) This requires shopt -s extglob to be enabled (and for safety, also shopt -s failglob, so that no file with the unusual name !(*999*) gets ...
user avatar
  • 267k
20 votes

Remove files without string in name

Just invert the name condition in find : find . -type f \! -name "*999*" Add -delete or -exec rm {} + to actually remove the matched files.
user avatar
  • 115k
19 votes
Accepted

Why can't I pipe `pwd` to `open` on macOS?

I don't have a Mac so I can't test it, but the solution should be something like: open "`pwd`" Not all programs take their input from stdin which would be necessary for the pipe to work.
user avatar
18 votes

GZip doesn't produce the same compressed result on macOS vs Linux

The format should be very stable, but see its description. It contains a field for operating system ID. Obviously that will differ for MacOS and Linux and FreeBSD and...
user avatar
  • 17.8k
14 votes
Accepted

mktemp on macOS not honouring $TMPDIR

/var/folders/qg/s5jp5ffx2p1fxv0hy2l_p3hm0000gn/ This is your Darwin user local directory. Its name is simply a modified base 32 encoding of the concatenation your MacOS User UUID and your MacOS (BSD)...
user avatar
  • 62k
13 votes

Why do I lose my ZSH history?

ZSH History file can be truncated/lost/cleaned for multiple reasons those can be: Corruption of the zsh history file (because of a power-cut/system-fail while a shell is opened, in this case fsck ...
user avatar
  • 12.7k
13 votes

How to install docker-engine in macOS without docker desktop?

There is an alternative to docker, it is podman. Install: brew install podman Download and prepare the VM: podman machine init Turn on the VM: podman machine start Uses as a docker: podman run -d -p ...
user avatar
  • 231
13 votes

Where can I find a complete list of format specifiers for the date command?

The manual for the C language function strftime() (man strftime) should contain all the date format specifiers across most Unix and Unix-like systems. The strptime() function has to do with parsing ...
user avatar
  • 915
12 votes

Replacing string in file with MAC OSX

How it to do with sed in OS X. I've created test file: $ cat test.txt tasdasdasd asd asd as d as d ddddddd ffdfdfdfdfdf Calling sed ('' is necessarily parameter): $ sed -i '' "s/as/replaced_ad/g"...
user avatar
12 votes

How can I create a shortcut to resize panes in a tmux window?

Below are my keybindings that let me resize a pane. It uses Alt + direction, where the keys for the directions are the same as in Vim: k h l j # Resize the current pane using Alt + direction ...
user avatar
12 votes

No xauth program; cannot forward X11

Both your client and the server are complaining that they can't find the xauth program. The "debug1: No xauth program" message comes from your client, saying it can't find a copy of xauth locally. The ...
user avatar
  • 2,701
12 votes
Accepted

MacOS quotation marks turning italic and breaking scripts

These aren't italic, they're the "typographically correct" open- and close-quotes. But they are pretty useless in a shell To disable them globally: System Preferences > Keyboard > Text ...
user avatar
  • 7,684
11 votes
Accepted

How to mirror directory structure and files with zero size?

GNU cp (from coreutils) can do this: cp -r --attributes-only original_folder/* mirrored_folder/ From man cp: --attributes-only don't copy the file data, just the attributes -R, -r, --recursive copy ...
user avatar
  • 38.2k
11 votes
Accepted

Move files to directory based on extension (zsh, macOS)

You're not doing anything wrong. It's totally normal when you begin scripting to have your first script be nothing but a list of commands one after another. But hopefully you will learn to go beyond ...
user avatar
  • 7,107
10 votes

How to move directory into a directory with the same name?

On macOS, you can install the rename command (a Perl script) using Homebrew: brew install rename Then using the -p (a la mkdir) to have it make any necessary directories, and -A to add a prefix: % ...
user avatar
  • 63.9k
10 votes

How to move directory into a directory with the same name?

As long as the contents are not sufficient to exceed the maximum parameter limits, (and you don't mind an "acceptable" error message) then it doesn't need to be any more complicated than this: mkdir ...
user avatar
  • 3,292
10 votes

GZip doesn't produce the same compressed result on macOS vs Linux

Gzip format is standard, the implementation - not necessarily. Wikipedia lists at least 5 free/oss independent implementations and there are also proprietary ones. Apple clearly outputs a different ...
user avatar
  • 279
10 votes

How to fix "VirtualBox VM quit unexpectedly" when running my Ubuntu 20.04 LTS VM on MacOS Catalina 10.15 in VirtualBox?

For me. I tried two solutions (pick one): Starting virtualbox with sudoer works for me. Disable Audio also works settings->Audo--> uncheck Enable Audio.
user avatar
10 votes
Accepted

How to set a value with newline by `env` command?

Your understanding is incorrect. When you store the content "hello\nworld" into a variable, the \n is interpreted literally. Only if you invoke tools such as printf or echo with -e flag, ...
user avatar
  • 11.8k
9 votes

Why can't I pipe `pwd` to `open` on macOS?

pwd | xargs open xargs shoves its standart input into the arguments of its first argument.
user avatar
  • 159
9 votes

Why can't I pipe `pwd` to `open` on macOS?

The other answers are totally correct. If you want an easy shorthand, you can do as @fd0 proposed, and just use open . to open the current directory. The current directory is named . (a single dot) ...
user avatar
  • 610
9 votes

How do I delete a directory that contains only '.' and '..', but rm says is not empty?

The directory entries . and .. are an artefact from the early 1970s, when UNIX did run on tiny machines and code needed to be tiny as well. So the people created real hardlinks to directories named . ...
user avatar
  • 17.9k
9 votes

Where can I find a complete list of format specifiers for the date command?

MacOS is POSIX compliant, and is certified as such. Therefore you can also check the POSIX documentation for date. Here it does list the available format specifiers: Conversion Specifications %a ...
user avatar
  • 88.9k

Only top scored, non community-wiki answers of a minimum length are eligible