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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
51 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.
joe's user avatar
  • 13
1 vote
1 answer
59 views

Can I force numfmt to always output a number scaled to Kilo instead of the auto-scale?

Can I make numfmt output the input number scaled to Kilo even when it is in another range, like in this sample Giga? > LC_NUMERIC="en_US.UTF-8" numfmt --to=si --format=%.6f --suffix=Wh ...
user640916's user avatar
0 votes
0 answers
19 views

date -d 'last month' yielding incorrect results? [duplicate]

I noticed an awkward (at least to me) behaviour of the date command: jasio@zuza:~> date -d 'this month' śro, 29 mar 2023, 15:51:42 CEST (1) jasio@zuza:~> date -d 'last month' (2) śro, 1 mar ...
Jasio's user avatar
  • 515
2 votes
0 answers
243 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 ...
mindgod's user avatar
  • 21
0 votes
2 answers
225 views

BusyBox's tar --exclude doesn't exclude

Extract a tar file with content dir1/dir2/file, using --exclude dir2 switch. The gnu tar excluded but busybox's tar doesn't. Use --exclude dir1/dir2 works fine, but why? Is there a way to exclude any ...
kkocdko's user avatar
  • 101
3 votes
2 answers
1k 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 ...
backslash enn's user avatar
2 votes
1 answer
346 views

How do I use modern coreutils on Mac?

How do I get modern coreutils on mac? I ran into this problem using csplit: foo.txt: foo 1 foo 2 foo 3 $: csplit foo '^foo$' '{*}' # error Double checking the manpage, man csplit, csplit on Mac is ...
Chris's user avatar
  • 903
-4 votes
3 answers
517 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/...
bashianer's user avatar
  • 153
0 votes
0 answers
14 views

How to escape standard input when "cat f - g" [duplicate]

man cat shows the following example: cat f - g Output f's contents, then standard input, then g's contents. How do you escape the standard input and proceed to output the 2nd ...
MattP's user avatar
  • 111
2 votes
0 answers
82 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 ...
smheidrich's user avatar
-1 votes
2 answers
117 views

Use Git Version of mv/rm etc When in Repository

Git has its own versions of commands such as mv and rm that we really ought to use when doing these operations inside repositories. However, I'm sure I'm not the only person who often forgets to do ...
ScottishTapWater's user avatar
0 votes
2 answers
62 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' $ ...
user avatar
2 votes
0 answers
157 views

What dictates the order of group listing with id and groups command

I am trying to work out what order the groups are listed by id and groups command (coreutils v8.22) I am using LDAP and have configured SSSD to read user and group information. My ldap server always ...
Rendalf's user avatar
  • 39
0 votes
3 answers
110 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 ...
Clément's user avatar
  • 296
1 vote
1 answer
57 views

Why do I need to specify `-o auto` for join's `-e` option to work?

With the following two simple files: a.txt 1 a 2 b 5 c b.txt 2 x 4 y 5 z The following command does not behave like expected: $ join -a 1 -a 2 -e 0 a.txt b.txt 1 a 2 b x 4 y 5 c z I would expect ...
iago-lito's user avatar
  • 2,631
9 votes
3 answers
3k 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 ...
user69136's user avatar
  • 113
1 vote
3 answers
109 views

Is there a unified stdout data format (for consistent/easy parsing) for core linux commands?

It seems that each core Linux command has a different stdout format. Also, these formats are not always easily/safely/consistently parsed by other scripts/apps. Is there a wrapper or specification or ...
Guy Langston's user avatar
1 vote
1 answer
128 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 ...
matt's user avatar
  • 517
0 votes
1 answer
342 views

How to intercept file descriptor of file opened with inotify or others on access?

I just finished an Operating Systems course at my University, and I want to start playing with systems level programs with Rust. One of things I'm looking for is how to intercept a file descriptor of ...
Matanya's user avatar
  • 177
0 votes
3 answers
513 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 ...
ojbqa's user avatar
  • 3
1 vote
1 answer
538 views

Preserve permissions and ownership with install command

When running install (GNU Coreutils implementation), I'd like to know if it is possible to preserve ownership and permissions of the source files. I know that by default it installs as 755, and you ...
Daniel M.'s user avatar
  • 297
2 votes
1 answer
143 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 <...
Jon's user avatar
  • 123
-1 votes
1 answer
377 views

How can I display directory file counts recursively with the ls command? [closed]

Under bash in Ubuntu, I want to ls -lah a directory and have it display file counts for directories recursively. That's to say I want it to count all files in the directories and their subdirectories....
Duncan Marshall's user avatar
3 votes
0 answers
272 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 ...
Atai Ambus's user avatar
0 votes
1 answer
205 views

Help me understand a script that uses csplit and sed

I wanted a simple way to export notes from the reference manager, Zotero. I start by selecting multiple notes and dragging them into a blank text file. I also want achieve "atomicity" of my ...
Christopher J Poor's user avatar
2 votes
1 answer
745 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 ...
Carla only proves trivial prop's user avatar
-1 votes
2 answers
1k views

ls: unparsable value for LS_COLORS environment variable zshell in fedora 33

I'm using zshell in fedora 33 OS. I've the configuration in my ~/.zshrc file Whenever I run ls command I get below error - ls: unparsable value for LS_COLORS environment variable How can I fix this ...
Rajkumar Natarajan's user avatar
1 vote
0 answers
387 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] ...
Zeta.Investigator's user avatar
2 votes
1 answer
763 views

GNU cp: What's the difference between `--link` and `--reflink=always`?

What's the difference between --link and --reflink=always? I use the following command as an mv substitute, and I am wondering if using --reflink is a better choice. command gcp -r --link --archive --...
HappyFace's user avatar
  • 1,493
0 votes
4 answers
339 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 ...
Mary's user avatar
  • 1
1 vote
2 answers
251 views

Making ls do a reasonable sort order, but not print Greek characters as "??"

Suppose I have the following files in a directory _y a b c x z β The following command lists them in the above order, as God intended: perl -e '@files = <*>; print join(" ",sort @...
user avatar
0 votes
2 answers
68 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 ...
Chris's user avatar
  • 3
1 vote
1 answer
2k views

What is %z useful for in GNU date?

I'm in the UK running these 2 commands (using gdate as I'm on a Mac with date (GNU coreutils) 8.32 installed): # A UK winter date, timezone in UK at this time is GMT = UTC $ gdate '--date=TZ="...
Matt's user avatar
  • 561
1 vote
0 answers
56 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 ...
wzzrd's user avatar
  • 3,700
2 votes
1 answer
395 views

Interleaving two binary files by fixed-size blocks

We have paste(1) which can interleave files by lines. Out of curiosity, I wonder if there's some binary equivalent. It should copy the first N bytes from file A to stdout, then the first N bytes of ...
7efkvNEq's user avatar
  • 121
0 votes
0 answers
39 views

man -k . is not working in gnu/linux [duplicate]

I am using manjaro and when i try command man -k . or apropos . or man -k . -s 2 to see all man pages it's giving me error like .: nothing appropriate. is it man different because i gnu coreutils ? ...
Visrut's user avatar
  • 135
3 votes
1 answer
111 views

Why does apropos and man -k omit or miss valid results?

For example, if I enter the following command: $ man -k compare The diff command is missing from the results, however the test command is not. I get the same results using apropos as expected. $ ...
metabind's user avatar
1 vote
2 answers
297 views

Find filenames difference between two directories (ignoring filename extension)

I have a lot of files that I need to keep in sync as example: ./regular/*.txt ./compressed/*.txt.bz2 When files get uploaded to ./regular I want to make a script to periodically check and bzip2 ...
luwu's user avatar
  • 13
-2 votes
1 answer
1k views

What is the difference between grep -r and find here?

I'm trying to recursively grep through files in a directory to find a certain string. The solution of my choice is: $ find . -type f -exec grep "string to find" {} \+ ... while using grep ...
Franz Wimmer's user avatar
24 votes
3 answers
7k views

Why is cp's option not to overwrite files called --no-clobber?

cp is a massively popular Linux tool maintained by the coreutils team of the GNU foundation. By default, files with the same name will be overwritten, if the user wants to change this behaviour they ...
TZubiri's user avatar
  • 393
2 votes
0 answers
45 views

ls output: group directory symlinks with directories [duplicate]

Using the --group-directories-first option I can group the ls output as follows: [a-z directories] [a-z files and symlinks] However, I would like symlinked directories to appear with the rest of the ...
JShorthouse's user avatar
0 votes
1 answer
316 views

GNU coreutils `sort` behave differently

I wanted to sort a list of data and I intended to sort it based on its first column which is an IP address. 192.168.1.100 192.168.1.101 192.168.1.110 192.168.1.119 192.168.1.20 192.168.1.30 192.168.1....
annahri's user avatar
  • 2,020
2 votes
1 answer
255 views

How can I find out more about the history of GNU coreutils commands?

Can I somehow find out more about the history of the development process of the GNU coreutils commands? For example, have su and runuser (which provide kind of similar functions, yet were decided to ...
finefoot's user avatar
  • 2,980
0 votes
1 answer
101 views

Why did GNU's expand convert a tab to less than 8 columns?

Using expand, I don't understand how many spaces it converts tabs to. From info expand: By default, expand converts all tabs to spaces. It preserves backspace characters in the output; they ...
SantaXL's user avatar
  • 365
12 votes
2 answers
1k views

Explanation of tac --before

-b, --before The separator is attached to the beginning of the record that it precedes in the file. And I can't understand the following output: $ echo -e "Hello\nNew\nWorld\n!" > file $ ...
SantaXL's user avatar
  • 365
4 votes
1 answer
2k views

Why is mktemp -u considered "unsafe"?

I read the --help text for mktemp recently (the man page wasn't available) and came upon this: -u, --dry-run do not create anything; merely print a name (unsafe) Why is this "unsafe"? Is ...
S.S. Anne's user avatar
  • 463
15 votes
5 answers
3k views

How to run a command 1 out of N times in Bash

I want a way to run a command randomly, say 1 out of 10 times. Is there a builtin or GNU coreutil to do this, ideally something like: chance 10 && do_stuff where do_stuff is only executed 1 ...
retnikt's user avatar
  • 319
1 vote
1 answer
536 views

What is the use of n option in cut command?

I'm learning about the cut command. In the man page of cut, they show the -n option like: -n (ignored) But I didn't understand the usage of the n option or when we would use it. Can anyone ...
Ganapathy's user avatar
  • 113
4 votes
1 answer
87 views

Why does ls sort results the way it does? [duplicate]

I'm just wondering why ls output is sorted the way it is: $ mkdir SortTest<br> $ cd SortTest<br> $ for a in {1..34}; do touch filename_$a.txt; done $ ls -l -rw-r--r-- 1 user user 0 Jun 28 ...
flups's user avatar
  • 51
1 vote
1 answer
687 views

Translating Linux stat(1) command into BSD stat(1) command

Background CLion's remote project feature currently doesn't support FreeBSD as a remote host OS, but I want to do some hacking and see if it works. By reading the log file, I think I have spotted (...
nalzok's user avatar
  • 369

1
2 3 4 5