Preface: While it may be quite satisfying to upvote an answer such as this and call it a day, please be assured that the GNU coreutils maintainers do not care about SO answer votes, & that if you actually want to encourage them to change, you need to email them as this answer describes.
Sometime this past year the maintainers have doubled-...
You can chose quoting style:
The same as:
Make it an alias, or set export QUOTING_STYLE=literal in your .bashrc to achieve pre-8.25 behavior.
With symlinks, tools have two things they can do:
Treat the symlink as a symlink ("preserving its nature"), or
Treat the symlink as the type of file that it points to.
Saying that -H "preserves its nature" is not a contradiction. Consider the alternative. If you use -L, any symlinks cp finds will be opened, and their contents copied to the target file ...
yes exhibits similar behavior to most other standard utilities which typically write to a FILE STREAM with output buffered by the libC via stdio. These only do the syscall write() every some 4kb (16kb or 64kb) or whatever the output block BUFSIZ is . echo is a write() per GNU. That's a lot of mode-switching (which is not, apparently, as costly as ...
It's not the default since for robustness reasons one may want a copy to take place to protect against data corruption. Also for performance reasons you may want the writes to happen at copy time rather than some latency sensitive process working on a CoW file and being delayed by the writes possibly to a different part of a mechanical disk. Note that from ...
A few points about the change.
It was introduced in coreutils v8.25, and alignment improved in v8.26
It only happens when outputting to terminals so doesn't break scripts
It disambiguates the output for users for files containing whitespace
It sanitizes output so it is safe to copy and paste
Output is now always valid to copy and paste back to shell
For GNU utilities, the full documentation is in the info page, where you can read:
-f Ignored; for compatibility with BSD versions of `touch'.
See historic BSD man pages for touch, where -f was to force the touch.
If you look at the source of those old BSDs, there was no utimes() system call, so touch would open the file in read+write mode, read one ...
“Clobber” in the context of data manipulation means destroying data by overwriting it. In the context of files in a Unix environment, the word was used at least as far back as the early 1980s, possibly earlier. Csh had set noclobber to configure > to refuse to overwrite an existing file (later set -o noclobber in ksh93 and other sh-style shells). When GNU ...
It's not a bug. The use case is for when you want to link a file to the same basename but in a different directory:
ln -s /etc/passwd
ls -l passwd
lrwxrwxrwx 1 xxx xxx 11 Jul 29 09:10 passwd -> /etc/passwd
It's true that when you do this with a filename that is in the same directory it creates a link to itself which does not do a whole lot of ...
In ksh, Bash, Zsh, Yash or BusyBox sh:
[ "$RANDOM" -lt 3277 ] && do_stuff
The RANDOM special variable of the Korn, Bash, Yash, Z and BusyBox shells produces a pseudo-random decimal integer value between 0 and 32767 every time it’s evaluated, so the above gives (close to) a one-in-ten chance.
You can use this to produce a function which behaves as ...
The [ binary residing under the /bin tree in many GNU/Linux distributions is not something to be alarmed off. At least in my Fedora 19 it is a part of the coreutils package, as demonstrated below:
$ rpm -qf /bin/[
and is a synonym for test to allow for expressions like [ expression ] to be written in shell scripts or even ...
This is documented, for Coreutils’ md5sum:
If file contains a backslash or newline, the line is started with a backslash, and each problematic character in the file name is escaped with a backslash, making the output unambiguous even in the presence of arbitrary file names.
(file is the filename, not the file’s contents).
b2sum, sha1sum, and the various ...
- 1 month will subtract one from the month number, and then if the resulting date is not valid (February 30, for example), adjust it so that it is valid. So December 31 - 1 month is December 1, not a day in November, and March 31 - 1 month is March 3 (unless executed in a leap year).
Here's quote from the info page for Gnu date (which is the date version ...
Your . trick can only be used when you're copying a directory, not a file. The -T option works with both directories and files. If you do:
cp srcfile destfile
and there's already a directory named destfile it will copy to destfile/srcfile, which may not be intended. So you use
cp -T srcfile destfile
and you correctly get the error:
cp: cannot overwrite ...
Because this is actually a standard term. As explained in Wikipedia:
In software engineering, clobbering a file or computer memory is
overwriting its contents. The Jargon File defines clobbering as
To overwrite, usually unintentionally: "I walked off the end of the
array and clobbered the stack." Compare mung, scribble, trash, and
Izkata's comment revealed the answer: locale-specific comparisons. The sort command uses the locale indicated by the environment, whereas Python defaults to a byte order comparison. Comparing UTF-8 strings is harder than comparing byte strings.
$ time (LC_ALL=C sort <numbers.txt >s2.txt)
How about ...
du without an output format specifier gives disk usage in blocks of 512 bytes, not kilobytes. You can use the option -k to display in kilobytes instead. On OS X (or macOS, or MacOS, or Macos; whichever you like), you can customize the default unit by setting the environment variable BLOCKSIZE (this affects other commands as well).
tac works with records and their separators, attached, by default after the corresponding record. This is somewhat counter-intuitive compared to other record-based tools (such as AWK) where separators are detached.
With -b, the records, with their newline attached, are as follows (in original order):
Output in reverse, this ...
The problem with cp/mv/ln as they were originally designed is that they're two commands in one (copy to and copy into).
cp A B
is either copy A to B or copy A into B (copy A to B/A) depending on whether B exists and is a directory or not (and more variations if B is a symlink to a directory).
That's bad because it's ambiguous. So the GNU implementations ...
A better question would be why is your shell writing the file so slowly. Any self-contained compiled program that uses file writing syscalls responsibly (not flushing every character at a time) would do it reasonably quicky. What you are doing, is writing lines in an interpreted language (the shell), and in addition you do a lot of unnecessary input output ...
By default, cp tests if its last argument is an existing directory. If this happens, cp creates a link inside that directory, with the base name of the source. That is, given the command
cp foo/bar wibble
if wibble is an existing directory then cp copies the source to wibble/bar. If wibble does not exist then cp links the source to wibble.
If you want to ...
You can put the grep in an if condition, or if you don't care about the exit status, add || true.
Example: grep kills the shell
$ set -e
$ echo $$
$ grep foo /etc/motd
$ echo $$
solution 1: throw away the non-zero exit status
$ set -e
$ echo $$
$ grep foo /etc/motd || true
$ echo $$
solution 2: explicitly test the ...
It's straightforward in shells that support process substitution, e.g. bash
$ echo foo | tee >(xsel)
$ xsel -o
Otherwise, you could use a FIFO (although it lacks convenience)
$ mkfifo _myfifo
$ xsel < _myfifo &
$ echo bar | tee _myfifo
$ xsel -o
 + Done xsel 0<_myfifo
As @samiam has stated the list is returned to you in a semi-random order via readdir(). I'll just add the following.
The list returned is what I would call the directory order. On older filesystems, the order is often the creation order that the file entries in the directory's table were added. There is of course a caveat to this, when a directory entry is ...
Stephen Kitt's answer covers the what and I will try to cover why this change was implemented. First, someone observed that a filename containing newlines1 could result in ambiguous output. For example, consider this output:
Does this mean there were two files foo and bar, or only ...
The command dircolors is specific to GNU coreutils, so you'll find it on non-embedded Linux and on Cygwin but not on other unix systems such as OSX. The generated settings in your .zshrc aren't portable to OSX.
Since you're using the default colors, you can pass an empty string to the
list-colors to get colors in file completions.
For colors with the ...
Since FreeBSD has no command dircolor and OS X has the base of FreeBSD you can't use it.
The simplest thing is to use
in your .zshrc and .bashrc and remove eval "$(dircolors -b)". To change the colors you can use the environment variable LSCOLORS.
You can find out more about it ...