Questions tagged [coreutils]
GNU Core Utilities are the GNU project's implementation of the core command-line tools of a POSIX system, including tools like ls, cp, mv, rm, etc.
242 questions
4
votes
2
answers
488
views
recursive ls - Ignore files only in specific sub-directories
So, ls -R is a command I use a lot to quickly verify the file structure of my projects, or check for any leftover files, as it's simple enough to use and read, and is part of coreutils (which means I ...
14
votes
1
answer
747
views
Why does `tail -c 4097 /dev/zero` exit immediately instead of blocking?
I observe that, on Ubuntu 24.04.2 with coreutils version 9.4-3ubuntu6, running:
$ tail -c 4097 /dev/zero
$ echo $?
0
exits immediately with a status code of 0. I expected the command to block ...
1
vote
0
answers
41
views
Msys64/mingw64 trouble, why its 'ln' command did `copy`
On Msys2 env.:
$ cd /c/msys64/mingw64/lib/
$ ln -s libz.dll.a libzlib.dll.a
But confusingly why
ln
command did copy
instead of linking it symbolically ?
$ ls -l libz*
-rw-r--r-- 1 abdu None 108700 ...
0
votes
1
answer
180
views
Replace string in file without temp file
I have a multi-gigabyte text file and I want to replace all occurrences of utf8mb4_0900_ai_ci in it with utf8mb4_unicode_520_ci.
Usually, I’d use sed -i for this as suggested here: find and replace a ...
0
votes
0
answers
96
views
Trailing slash in GNU and BSD cp and find commands [duplicate]
What might be a reason that BSD cp and find don't "like" a trailing slash for directory names?
| | cp | mv |
|-----|--------------------------|...
1
vote
2
answers
148
views
Where do I find documentation for the output of ls -l?
There have been multiple questions asked about this, like Understanding ls output, What are columns in ls -la?, What does 'ls -la' do?, What do the fields in ls -al output mean?, etc..
I've also come ...
2
votes
1
answer
200
views
Why does sort on Linux and on Cygwin return different results?
Scenario:
# on Linux
$ cat r456.txt
e+e+l
e+e-c
$ cat r456.txt | sort
e+e-c
e+e+l
$ sort --version
sort (GNU coreutils) 8.30
# on Cygwin
$ cat r456.txt
e+e+l
e+e-c
$ cat r456.txt | sort
e+e+l
e+e-...
2
votes
2
answers
196
views
Why is there manpage for sync(1) and sync(8) and how do they differ?
I see there are two different utilities in Linux manpages and I don't understand the difference.
There is sync(1) and sync(8), and they look eerily similar.
https://linux.die.net/man/8/sync
https://...
0
votes
1
answer
120
views
What is the default behavior of GNU cp when copying from a symbolic link?
Can someone elaborate on this description in the official docs?
When copying from a symbolic link, cp normally follows the link only when not copying recursively or when --link (-l) is used.
2
votes
0
answers
929
views
What is the exact source of Architecture info in lscpu command
Tl;dr
I need to mock info about CPU architecture on the server for testing purpose. The only way that I can achieve it, is by changing info source about CPU architecture, that is used by lscpu command ...
5
votes
2
answers
8k
views
What precisely does cp -b (--backup) actually do?
Before you hit me with the obvious, I know, the backup option makes a backup of a file.
But the thing is, the cp command in general backs up a file. One could argue a copy of a file is a backup.
So ...
-4
votes
3
answers
912
views
coreutils ls summary
Why is there no summary option in coreutils ls command, like MS-DOS/Windows has?
With summary option I mean:
count the files and dirs and sum up their sizes.
Update:
It should read: "Even DOS/...
2
votes
0
answers
286
views
Does mv across filesystems flush the destination filesystem cache between copy and delete?
mv is implemented as a simple rename() whenever possible, falling back to copy-then-delete whenever renaming doesn't work. In practice (but not in theory), these two cases correspond to source and ...
0
votes
2
answers
170
views
Using cp -u but only if content is different
How to use cp -u to only copy if content is different, it fails when doing as below
$ cd /tmp/exper ; cp -v ~/Downloads/C/test.c . ; sudo chmod -R 777 .
/home/budi/Downloads/C/test.c -> 'test.c'
$ ...
0
votes
3
answers
218
views
Seq but multiplying by the step instead of adding it
seq "prints a sequence of numbers to standard output", and, as far as I know, it can only increment the counter by adding.
For instance,
seq 0 3 10
0
3
6
9
tells seq to count from 0 to 10 ...
9
votes
3
answers
4k
views
Move files to directory based on extension (zsh, macOS)
I want to have a script to automatically move all files
into a directory structure that I have in place
(it looks like ~/jpg, ~/png, ~/mp3, ~/zip, and so on).
So far, this is almost doing exactly ...
3
votes
1
answer
204
views
ln: create relative symlink to a relative symlink
I want to create a relative symlink pointing to a relative symlink, not to the relative symlink's target. It seems that when creating a relative symlink ln resolves TARGET instead of pointing to the ...
0
votes
3
answers
1k
views
Is there a Linux command that removes just the first character of every file?
Is there a Linux command that can remove the first character on the first line for every file in a folder, and then save it?
Many online resources cover doing this for every line instead of just the ...
2
votes
1
answer
165
views
If the `-p` flag not needed anymore in `mkdir` 9.0?
I can't find any reference of this change of behaviour
$ mkdir --version
mkdir (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <...
4
votes
0
answers
1k
views
Are there any "richer" alternatives to cp and mv (like bat to cat and exa to ls)?
ls has exa. cat has bat. I don't know of a direct alternative to rm, but it also has rmtrash.
All of these can usually work as drop-in alias replacements, retaining usual function and options of their ...
2
votes
1
answer
1k
views
How to treat a symbolic link as a file itself (instead of the one it points to)?
Out of curiosity i wanted to open a symlink as itself instead of the file it points to, just to see how it looks like. While there are ways to see what file it points to like using readlink and ways ...
1
vote
0
answers
648
views
Is jq internal sort slower than GNU sort?
While filtering through this json file I did a benchmark and found out utilizing jq's internal sort and unique method is actually 25% slower than sort --unique!
Command
Mean [ms]
Min [ms]
Max [ms]
...
0
votes
4
answers
448
views
what timedate value is always greater than any timedate?
What timedate value is always greater than any timedate?
In a script, I want to provide an argument to variable duration so that the loop will run forever until I kill the process:
# `duration` has a ...
0
votes
2
answers
95
views
coreutils date does not return time zone when called from script
In terminal, the output of the lines
TZ="Australia/Broken_Hill" date -d '2021-4-26 09:29'
TZ="Australia/Broken_Hill" date -d '2021-4-26 09:29' +%Z
is
Mon Apr 26 09:29:00 AM ACST ...
1
vote
0
answers
57
views
Inconsistent output of cp -v command between machines
On two different machines I maintain, cp -v's output is different. On one box, both src and dest are quoted, on another box, the first quote around both src and dest is a backtick:
Box one (recent ...