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.

learn more… | top users | synonyms

42
votes
3answers
5k views

How does `yes` write to file so quickly?

Let me give an example: $ timeout 1 yes "GNU" > file1 $ wc -l file1 11504640 file1 $ for ((sec0=`date +%S`;sec<=$(($sec0+5));sec=`date +%S`)); do echo "GNU" >> file2; done $ wc -l ...
1
vote
1answer
18 views

custom sysconfdir for coreutils

I compiled coreutils with --sysconfdir=/test/etc instead of default /etc, moved /etc/group to /test/etc/group, and chgrp failed with chgrp: invalid group: $groupname. How can I fix that and ...
21
votes
4answers
1k views

What is the added value of the -T option in GNU cp and mv?

Why do some GNU Coreutils commands have the -T/--no-target-directory option? It seems like everything that it does can be achieved using the semantics of the . (self dot) in a traditional Unix ...
2
votes
6answers
9k views

ls command - define number of columns

Is there a way to define the number of columns in ls output? I got this far: ls -C sorts in columns and ls -1 produces one column. --tabsize = option to produce two columns resulted in what looks ...
47
votes
11answers
34k views

Correct locking in shell scripts?

Sometimes you have to make sure that only one instance of a shell script is running at the same time. For example a cron job which is executed via crond that does not provide locking on its own (e.g. ...
4
votes
2answers
74 views

Wrap and indent text using coreutils

Short version I would like to create a tabular display of multiline text, similar to the following: all Build all targets document Create documentation of source files in the subfolders ...
4
votes
2answers
124 views

How to find out if a file on btrfs is copy-on-write?

I know that cp has a --reflink option to control full copies vs. copy-on-write "copies". On btrfs, can I use ls (or some other command) to find out whether a file shares (in a copy-on-write senses) ...
1
vote
1answer
43 views

What metadata of a file does cp preserve by default?

By default, what file metadata does cp preserve, and what file metadata not? For example, if I am correct, the mtime is changed, the access list is preserved, and I would to know about the other ...
22
votes
4answers
2k views

What is the use of the -f option for `touch`?

From man touch: -f (ignored) But I don't get what is meant by ignored. I've tried following: $ ls -l file -rw-rw-r-- 1 pandya pandya 0 Mar 20 16:17 file $ touch -f file $ ls -l file -rw-...
1
vote
1answer
147 views

Seq performance hit when specifying a format string

Running seq (GNU coreutils 8.21) without specifying a format string runs extremely quickly compared with any possible format I tried: $ time seq 1e8 > /dev/null seq 1e8 > /dev/null 0.68s ...
0
votes
0answers
19 views

How to replace GNU core utilities with Busybox in a Linux system [duplicate]

Is it possible/safe to replace the GNU coreutils with Busybox in a GNU/Linux system? What else (binutils, bash) could be replaced? How much free disk space would I get with that? If possible, give ...
4
votes
4answers
553 views

Why can't mv deal with existence of same-name directory in destination?

mv can't move a directory to a destination with a same-name directory: $ mv fortran/ imperative_PLs/ mv: cannot move ‘fortran/’ to ‘imperative_PLs/fortran’: Directory not empty Why does mv not ...
3
votes
1answer
88 views

How does unexpand command really work?

I've already read some explananations about unexpand, but either I don't understand, or is not working as expected. Let's consider the following example: [root@hope log]# echo "A12345678B" | tr '[1-...
0
votes
2answers
102 views

Is Chromium OS a GNU/Linux distro?

I want to ask, if Chromium OS is a GNU/Linux distribution or is it a non-GNU Linux-based operating system like Android, webOS or Syllable Server. Does Chromium OS use GNU C Library, GNU coreutils etc.,...
1
vote
0answers
36 views

Conditional expressions in shell: What are the differences between [ vs [[ [duplicate]

I just wondered about some people writing if [[ <expr> ]]; then ... in answers here when I out of habit would use if [ <expr> ]; then ... Doing a quick research reveals that [[ ]] ...
4
votes
1answer
167 views

Debian wheezy updates broke tr command [closed]

After I updated the following packages yesterday in debian wheezy, tr command stop working. Start-Date: 2016-02-16 23:10:06 Commandline: apt-get dist-upgrade Upgrade: libkrb5-3:amd64 (1.10.1+dfsg-5+...
0
votes
0answers
82 views

LFS error - Coreutils (step 6.29)

As succinctly as I can put, I've gotten all the way to 6.29 in the book (Coreutils) and I seem to be receiving the following error when running the "make" command. Full output is as follows: root:/...
0
votes
0answers
30 views

what's the use of yes (coreutils)? [duplicate]

I notice my shell has a util named "yes" It just output a infinite "y" string line by line What's the use of this "core util" of "yes" ? Usage: yes [STRING]... or: yes OPTION Repeatedly output a ...
3
votes
3answers
55 views

Symmetric Difference Pipe?

I have a command that produces a lists of strings followed by newlines, a, and a file containing a list of strings followed by newlines, b.txt. I need a command that calculates the symmetric ...
0
votes
1answer
60 views

Strange cut behavior

I'm using cut (GNU coreutils) 8.24. The command: echo "TEST=test" | cut -d"=" -f2- outputs Ttest. I don't think this is the intended behavior. Am I using it wrong or is there something wrong with my ...
0
votes
2answers
46 views

Unix equivalent of `du -sb` to get summarized size in bytes

On Linux using GNU du to calculate the size of directory recursively in bytes I can run: du -sb /etc What is equivalent syntax for BSD du based on the fact that -b parameter is not available?
4
votes
1answer
78 views

Why does a '.' work in chown?

Why does GNU chown user.group work? The docs say nothing of the syntax being supported. Is there a juicy story behind it?
4
votes
1answer
523 views

`set -e` and `grep` idiom for preventing premature exit from shell script when pattern not found

Help required - in the context of shell scripting on a GNU/LINUX bash: I always use set -e. Often, I would like to grep and do not always want the script to terminate execution if grep has an exit ...
10
votes
5answers
1k views

Is there a practical use for the GNU factor command?

Looking through the GNU Coreutils, I spotted the factor command, that I had never noticed before. Reading the man page: Print the prime factors of each specified integer NUMBER. If none are ...
12
votes
2answers
2k views

coreutils that are utf aware?

When I used cut today, I found out it doesn't treat a UTF-8 character as a character, but 3 characters because it's 3 bytes long. This seems to be generally true for many tools. Are there versions ...
2
votes
2answers
296 views

Has the GNU coreutils stat tool changed?

Has the GNU coreutils (8.6) version of stat changed? After a recent update, some scripts I wrote that call stat are not working as expected; in particular, I had been making use of stat -c %Y "${...
0
votes
1answer
71 views

Error in 'date -d' command

Hmmm... Right now (Sat Oct 24 00:36:56 CDT 2015) on my Arch Linux system there appears to be a problem with the date command: $ date -d "+8 days" "+%A %d %B %Y" Sunday 01 November 2015 $ date -d "+9 ...
4
votes
1answer
131 views

mv overwrites read-only file without prompting

The GNU Coreutils manual for mv says: If a destination file exists but is normally unwritable, standard input is a terminal, and the -f or --force option is not given, mv prompts the user for ...
5
votes
1answer
113 views

When is next Monday?

On my home computer (Xubuntu 14.04), I have zev@home:~$ date +%F 2015-10-05 zev@home:~$ date +%F -d "next Monday" 2015-10-12 whereas at work (Red Hat 5.11), I have zev@work:~$ date +%F 2015-10-...
2
votes
1answer
200 views

Installed coreutils on CentOS for sort --human-readable flag but it still doesn't work

I'm trying to do du -h | sort -h, but my CentOS 5.7 doesn't have -h flag for sort. So I installed coreutils Updated: coreutils.x86_64 0:5.97-34.el5_8.1 Complete! yet sort still doesn't have ...
6
votes
1answer
157 views

How can I delete a file named “--append”? [duplicate]

By mistake I have created a file named : --append. How do I delete it? Simply entering the usual command, rm -f --append, doesn't work.
25
votes
2answers
1k views

Why does ln -s accept a single argument

> cd /tmp > ln -s foo > ls -alhF /tmp lrwxrwxrwx 1 user user 3 Jul 29 14:00 foo -> foo Is this a bug in ln or is there a use case for symlinking a file to itself? This is with ...
8
votes
5answers
624 views

How intelligent are unix utilities?

Unix utilities like sort, find, grep, diff et al are very handy to perform quick tasks, sometimes without writing any code at all. I wanted to know what algorithms do they internally use and how do ...
5
votes
1answer
175 views

Is there a command line tool to manage unix signals?

Is there a command runner like env, nice, nohup, etc., that can run a program with modified signals? In my case, I need something to reset SIGINT to SIG_DFL. Why do I need this? Because non-...
2
votes
1answer
290 views

sudo ls not showing hidden files on Linux

Today I discovered that sudo ls shows hidden files (that is, those that have names starting with .) on OS X. This surprised me so much that I asked a question about this behaviour, which I still find ...
16
votes
4answers
3k views

Why is cp --reflink=auto not the default behaviour?

Why is cp --reflink=auto not the default behaviour? Could it cause any harm to enable it? Is it possible to enable it at compile time, so it is used all across the system, not just in interactive ...
6
votes
1answer
3k views

How does the “1 month ago” option in date command work?

I'm not sure if this gets the past date within the current day or if it only takes 30 or 31 days to it. e.g. If the current date is March 28th, 1 month ago must be February 28th, but what happen ...
4
votes
2answers
373 views

change file size format when using stat

The formatting character %s makes stat print the filesize in bytes # stat -c'%A %h %U %G %s %n' /bin/foo -rw-r--r-- 1 root root 45112 /bin/foo ls can be configured to print the byte size number ...
12
votes
4answers
55k views

Storing output of command in shell variable [duplicate]

I have an operation using cut that I would like to assign result to a variable var4=echo ztemp.xml |cut -f1 -d '.' I get the error: ztemp.xml is not a command The value of var4 never gets ...
0
votes
1answer
217 views

cp options --no-clobber vs. --update

I want to copy a single file if (and only if) the destination does not exist. The source file changes rarely, maybe once a month. The destination almost never exists. Are there any differences ...
9
votes
3answers
634 views

Which version of X introduced feature Y?

A big part of my daily job is developing software for use on machines with different versions of the same software, like bash, find, and grep. When encountering a feature which would be useful for ...
2
votes
1answer
1k views

what are practical uses of stdbuf or nohup?

I have to finish a writeup of a few coreutils commands for a course at the moment, and I can't think of a starting point for a small practical code example that demonstrates the potential uses of ...
14
votes
3answers
995 views

/usr/bin/ptx: Can you provide a use case or two?

I was going through the list of files included in coreutils and I was able to come up with an example of how I could personally use all of the commands provided except for ptx. Can you give one or two ...
0
votes
1answer
185 views

*ls* font differences between files and folders with “--color” option

I have recently switched to urxvt from xterm for better unicode support and it does much better as to the font fallback. However I find an interesting issue: names of files and folders are rendered ...
2
votes
1answer
214 views

How can I cross compile the dd linux tool for arm?

I need to cross-compile a full version of dd because my device only has a busybox one that doesn't support many options. Where do I get the source for it? I've been looking on the kernel repo online ...
4
votes
1answer
2k views

Install only a few GNU coreutils?

Is there a way to build and install only a few of the GNU coreutils? The README in coreutils-8.19.tar.xz lists 100-odd, but the INSTALL doesn't say how to install only a few, and the Makefile is (to ...
8
votes
2answers
2k views

How is the order in which tar works on files determined?

$ touch dir/{{1..8},{a..p}} $ tar cJvf file.tar.xz dir/ dir/ dir/o dir/k dir/b dir/3 dir/1 dir/i dir/7 dir/4 dir/e dir/a dir/g dir/2 dir/d dir/5 dir/8 dir/c dir/n dir/f dir/h dir/6 dir/l dir/m dir/j ...
11
votes
3answers
11k views

Mac OS X: dircolors not found?

I just switched to a Macbook Air. I installed zsh using homebrew, but when I use some of the code that I (originally had) in my .zshrc, I get an error saying that .dircolors was not found. Below is ...
2
votes
1answer
64 views

Difference between / and // [duplicate]

On the bash prompt one, three or more slashes (/,///,////, ...) are treated as a single slash, whereas two slashes (//) are left as is: 12:07 $ cd / 12:07 $ pwd / 12:07 $ cd // 12:07 $ pwd // 12:07 $ ...
20
votes
3answers
2k views

Why is coreutils sort slower than Python?

I wrote the following script to test the speed of Python's sort functionality: from sys import stdin, stdout lines = list(stdin) lines.sort() stdout.writelines(lines) I then compared this to the ...