Hot answers tagged

55

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 implementation and used parameters. So there's no guarantee at all that Apple GZip and gzip 1.6 will return the same compressed output. These outputs are all valid GZip ...


34

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:00:32.681184 CoreAudio: macOS 10.14+ detected, checking audio input permissions (then the system crashes...)


31

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 link count of 2). This implies that your filesystem has managed to get itself into an inconsistent state and that you should probably run fsck on it. On macOS,...


28

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 "$PWD" or simply $ open . as pointed out in the comments below. With the -f flag, open can be made to read from standard input, but only to open whatever it ...


21

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 would work too The mktemp -d command will create a directory at the given path, with the X-es at the end of the pathname replaced by random alphanumeric ...


19

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.


18

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 removed by mistake if all filenames contain 999). The pattern !(*999*) will match any name in the current directory, except those names matching *999*. To also ...


17

Just invert the name condition in find : find . -type f \! -name "*999*" Add -delete or -exec rm {} + to actually remove the matched files.


17

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...


12

/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 ID. The first two letters of the encoding are used as a "bucket" system to attempt to keep directory sizes low. Those two characters are the encoded ...


12

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 > uncheck "Use smart quotes and dashes" To disable them in-application, if the menu is available, deselect "Smart Quotes" in the Edit &...


10

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: % mkdir -p foo/bar; touch foo/{a,b}.txt foo/bar/c.txt % rename -p -A foo/ foo/* % tree foo foo └── foo ├── a.txt ├── b.txt └── bar └── c.txt ...


10

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 foo/foo mv foo/* foo/foo Amendment to handle hidden files: mkdir foo/foo mv foo/{.,}* foo/foo


10

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 version string. The format and the algorithm both allow for a lot of freedom and a lot of design choices that are either matter of taste and/or work better in ...


10

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 directories recursively Using find command as OP says xe is on MacOS and cp command has no --attributes-only option: find original_folder/ -type d -exec \ ...


9

pwd | xargs open xargs shoves its standart input into the arguments of its first argument.


9

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) in Unix, the parent directory .. (two dots).


9

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 . and ... This bad idea causes the hard link count of an empty directory to be 2. Today, this is nonsense and the POSIX definition since 1988 is that these ...


9

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


8

Technically, it's a bug, because POSIX states that all pathnames for other files encountered in the hierarchy shall consist of the concatenation of the current path operand, a <slash> if the current path operand did not end in one, and the filename relative to the path operand But the double slash doesn't make any difference, so ./path/here//foo ...


8

I suggest the other way around. Don't move the directory, but only its content: . └── foo ├── a.txt └── b.txt mkdir foo/foo . └── foo ├── foo ├── a.txt └── b.txt cd foo mv $(ls | grep -v '^foo$') foo cd - . └── foo └── foo ├── a.txt └── b.txt If you have bash, you can also do shopt -s extglob cd foo mv !(foo) ...


8

Sourcing an rc file rarely if ever works in practice, because people rarely write them to be idempotent. A case in point is your own, where you are prepending the same directory to the fpath path every time, which of course means that searching that path takes a little longer each time. No doubt this isn't the only place where you are doing that sort of ...


8

-F field separator in awk. Here we are using 2 field separators. (either { or } ) VBoxManage list vms | awk -F"[{}]" '/Test Machine/{print $2}'


7

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 "Remote: No xauth program; cannot forward X11" message is from the server, saying it can't find xauth either. The default location for both client and server ...


7

You may find the shell $OLDPWD shell variable useful (defined by POSIX). For example, you could define a shell function overriding the original cd command: cd() { command cd "$@" && printf '%s -> %s\n' "${OLDPWD}" "${PWD}"; } Excerpt from the Unix man page you should read: If, during the execution of the above steps, the PWD environment ...


7

awk -F '= ' '/CURRENT_PROJECT_VERSION/{$2=$2+1";"}1' OFS='= ' input > output Tests cat file SOME_DUMMY_VALUE = -1; CURRENT_PROJECT_VERSION = 4; SOME_SECOND_DUMMY_VALUE = -1; CURRENT_PROJECT_VERSION = 4; awk -F '= ' '/CURRENT_PROJECT_VERSION/{$2=$2+1";"}1' OFS='= ' file SOME_DUMMY_VALUE = -1; CURRENT_PROJECT_VERSION = 5; SOME_SECOND_DUMMY_VALUE = -1; ...


6

Apple configured ncurses with termcap support (in addition to the default terminfo): config.status file showing the configure options. infocmp calls _nc_read_file_entry to obtain its data. tput calls setupterm, which goes to _nc_read_entry, which calls _nc_read_tic_entry, which does call _nc_read_file_entry if there's a problem in _nc_read_tic_entry, then ...


6

You've pretty much nailed it already. You could pick a different name for the transient directory, such as the target name with the current date/time in nanoseconds and our PID as a composite suffix, but this still presupposes the directory doesn't already exist: dir=foo # The directory we want to nest now=$(date +'%s_%N') ...


6

mkdir foo/foo && mv foo/!(foo) foo/foo You need to cd into the directory where the source folder (foo) is. Then run the command above. It will create a folder called of the same name and move the contents of the parent foo into the child foo directory (except the child directory, hence the ! designation). If the child foo directory already exists ...


6

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 need to be setup to run when the system fail) Zsh config file is not loaded (for example if $home env variable is not defined) Unsupported character on history ...


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