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
2
votes
1answer
101 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 <...
-1
votes
1answer
50 views

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

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....
2
votes
0answers
43 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 ...
0
votes
1answer
57 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 ...
0
votes
0answers
44 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
votes
2answers
59 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 ...
1
vote
0answers
61 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
1answer
35 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 --...
0
votes
4answers
280 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 ...
1
vote
2answers
98 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 @...
0
votes
2answers
20 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 ...
0
votes
0answers
9 views

how to count number of null bytes in stream? [duplicate]

i basically want find /dir -print0 | wc -0 , unfortunately wc doesn't have a 0/look-for-nulls argument; this works: find /dir -print0 | php -r '$ret=0;while(!feof(STDIN)){$ret+=substr_count(...
1
vote
1answer
132 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="...
1
vote
0answers
43 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 ...
2
votes
1answer
122 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 ...
0
votes
0answers
24 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 ? ...
2
votes
1answer
29 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. $ ...
1
vote
2answers
88 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 ...
-1
votes
1answer
375 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 ...
23
votes
3answers
5k 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 ...
2
votes
0answers
43 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 ...
0
votes
1answer
168 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....
2
votes
1answer
153 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 ...
0
votes
1answer
61 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 ...
12
votes
2answers
984 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 $ ...
2
votes
1answer
1k 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 ...
15
votes
5answers
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 ...
1
vote
1answer
443 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 ...
4
votes
1answer
79 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 ...
1
vote
1answer
347 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 (...
0
votes
0answers
49 views

Filter out items that belong to the Source Packages

Here I have a Manifest of Ubuntu I would like to list out only the Source Packages and not the containing items. binutils 2.31.1-6ubuntu1 binutils-common:amd64 2.31.1-6ubuntu1 binutils-x86-64-...
3
votes
1answer
4k views

When does `mv` change the timestamp of a file and while does it not?

Moving directory without modifying timestamp says that mv changes the timestamp of a directory. When I mv a file from an external hard drive to another external hard drive, it also changes the ...
-2
votes
1answer
220 views

Does mv not remove transferred files from source while other files are still in transfer?

I am moving 100G files from an external hard drive to another external hard drive, mv /external/hdd1/sourcedir /external/hdd2/destdir While it is in process, I found that the files copied to the ...
2
votes
2answers
804 views

Does the size of the random_source file matter?

Some GNU coreutils utilities like sort and shuf use a file as what effectively serves a seed. Does the size of the file matter? The recommended way, https://www.gnu.org/software/coreutils/manual/...
1
vote
1answer
115 views

Is there a fast tool to show all the unique unicode characters in a file and their count?

Does anybody know a tool to tabulate all the unique unicode characters and their counts in a file?
8
votes
2answers
2k views

How to find a partial directory path?

Suppose I don't know where my Django source is stored, but I know that it contains these directories in this way: django/contrib/admin. How can I use the find command or any more appropriate ...
6
votes
2answers
209 views

Why does GNU Core Utilities stat (including du and ls) report the following sizes (ext4 in GNU/Linux)?

If I have the following contents in a directory: empty_dir: Empty directory. empty_file: Empty file. one_char: File consisting of one character. several_blocks: File consisting of several blocks (but ...
1
vote
1answer
755 views

Awk doesn't exit despite "exit 0" command

I have the following command: sudo docker logs -f <id> | awk '/Listening on / {print $3; exit 0;}' From what I understand, awk should find the first line that matches the pattern, print the ...
3
votes
1answer
114 views

Should I never use stdbuf's fully buffered mode?

On my system (a recently updated Arch Linux), the manpage for stdbuf has the following in the "BUGS" section: On GLIBC platforms, specifying a buffer size, i.e., using fully buffered mode will ...
1
vote
2answers
714 views

What is a good command for moving a directory containing relative symbolic links to files outside the directory?

I like to use relative symlinks when possible because they stay valid even when my filesystem is mounted in a non-root location, for example if I am accessing it remotely. However, if I move a ...
2
votes
1answer
103 views

If a string has a blank within it, can I still use tsort on the string?

coreutils manual says tsort reads its input as pairs of strings, separated by blanks, indicating a partial ordering. If a string has a blank within it, according to the manual, I can't use tsort ...
2
votes
2answers
355 views

tsort: -: input contains an odd number of tokens

coreutils manual says tsort reads its input as pairs of strings, separated by blanks, indicating a partial ordering. The output is a total ordering that corresponds to the given partial ...
-3
votes
1answer
752 views

How does `cat` work so that it allows reading a file line as an array element? [duplicate]

In bash, we can read an file into an array, so that each line in the file becomes an element of the array. $ arr=( $(cat myfile) ) I was wonder how cat works so that it allows reading a file line as ...
-2
votes
1answer
183 views

how can I provide files as inputs to `tsort`? [closed]

The input to tsort can be provided as in this example: $ tsort <<EOF a b c b c d e EOF If I have two files as inputs instead, a b c and b c d e how can I provide the two files in bash as ...
0
votes
1answer
110 views

Can I merge-sort two sorted files by using comm?

comm assumes its two inputs are sorted. Is it correct that it works in the same way as the merge sort algorithm? If yes, can I use comm to merge-sort two sorted files? Thanks.
0
votes
2answers
142 views

Is it correct that `od` can't show binary number?

Is it correct that od can't show binary number? I can't find an argument to provided to its -t option for showing binary number. I feel it is natural to expect od to show binary number, or do I miss ...
0
votes
1answer
39 views

Is the an elegant way to select rows in a file where a given column has a given value?

I have a file with a lot of lines like this 0 file:/home/knappen/somefilename.txt 7 0.2838356973995272 19 0.21823286052009455 18 0.10121158392434988 15 0....
3
votes
1answer
787 views

Alternatives of ls: dir and vdir [duplicate]

When I check the coreutils, I found that GNU Coreutils 10 Directory listing This chapter describes the ls command and its variants dir and vdir, which list information about files. • ls invocation: ...
-1
votes
1answer
72 views

Refer to gnu-manual page from bash

I installed the latest GNU/Bash and gnu coreutils on Mac $ bash --version GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin18.0.0) check the coreutils with a g prefix $ gls -l $(which gls) ...
0
votes
1answer
360 views

`--prefix=/`,`--program-prefix=g` and `--without-gmp` mean

When I install the coreutils, I found that ./configure --prefix=/usr/local/Cellar/coreutils/8.30 --program-prefix=g --without-gmp What does the --prefix=/, --program-prefix=g and --without-gmp mean?

1
2 3 4 5