61
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 ...
- 656
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 ...
- 497k
59
votes
Accepted
How can I set the default editor as nano on my Mac?
Set the EDITOR and VISUAL environment variables to nano.
If you use bash, this is easiest done by editing your ~/.bashrc file and adding the two following lines:
export EDITOR=nano
export VISUAL="...
- 306k
59
votes
Accepted
Why does awk -F work for most letters, but not for the letter "t"?
Because:
Normally, any number of blanks separate fields. In order to set the
field separator to a single blank, use the -F option with a value of
[ ]. If a field separator of t is specified, awk ...
- 126k
48
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 ...
- 581
35
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:...
- 451
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 ...
- 306k
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 "...
- 306k
28
votes
Accepted
Why does 'ls' only display contents when I'm in a certain directory?
The difference is physical vs. logical treatment of ..:
You apparently have two separate Downloads directories:
one is /Users/ciprian/Downloads
the other is /Users/ciprian/Library/CloudStorage/...
- 77.4k
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 ...
- 306k
21
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.
- 126k
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 ...
- 306k
20
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 may differ for macOS and Linux and FreeBSD and ...
- 18k
20
votes
What is the convention for options/questions in terminal?
If you just hit enter, it assumes the part in brackets. In your case, the default is “n”.
- 962
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.
- 7,534
19
votes
MacOS Terminal start up slow, the window title transitions between "login", "env", "bash" then "zsh" - but /bin/zsh starts fast in isolation
Ok turns out homebrew added around 100 calls to set itself in my ~/.zprofile file
- 546
16
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 ...
- 13.4k
16
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 ...
- 261
15
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)...
- 64.5k
15
votes
What is the convention for options/questions in terminal?
zsh is not a terminal, it's just a shell, a programming language with an interactive mode specialised in running other commands.
Terminal emulators such as xterm, gnome-terminal are configured to run ...
- 497k
14
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"...
- 4,102
14
votes
How to install docker-engine in macOS without docker desktop?
On my Macbook, I've installed docker via homebrew with
brew install docker docker-compose docker-machine xhyve docker-machine-driver-xhyve
(though this was way before docker desktop became non-free, ...
- 30.5k
14
votes
Accepted
tr command unable to process colour output piped from grep
To output matches in colour, grep writes colouring escape sequences before and after the match.
Those are instructions to the terminals to change their background and/or foreground colour.
It's ...
- 497k
13
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
...
- 7,327
13
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 ...
- 2,845
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 ...
- 1,445
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 ...
- 7,873
11
votes
How do I install htop in mac OS X?
I installed htop 0.8 (update: now 2.0.1) from MacPorts with
sudo port install htop
- 332
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 ...
- 39.7k
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 ...
- 7,891
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
macos × 2666bash × 400
linux × 251
terminal × 234
shell-script × 160
shell × 146
command-line × 141
zsh × 140
ssh × 128
sed × 96
ubuntu × 94
macintosh × 83
files × 80
permissions × 76
find × 72
text-processing × 63
grep × 62
filesystems × 55
networking × 48
awk × 46
bsd × 46
path × 45
ls × 43
x11 × 40
homebrew × 40