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

40
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 ...
3
votes
1answer
40 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) ...
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
45 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
2answers
27 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?
0
votes
0answers
47 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: ...
4
votes
1answer
70 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?
0
votes
1answer
50 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
88 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 ...
4
votes
1answer
225 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 ...
5
votes
1answer
72 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 ...
6
votes
1answer
144 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.
0
votes
1answer
55 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 ...
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 ...
5
votes
1answer
137 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 ...
2
votes
1answer
268 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 ...
6
votes
1answer
1k 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
298 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 ...
0
votes
1answer
154 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 ...
2
votes
1answer
458 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 ...
0
votes
1answer
139 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
155 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 ...
2
votes
1answer
165 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 ...
2
votes
1answer
62 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 $ ...
18
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 ...
0
votes
0answers
23 views

Set default editor for 'info coreutils' [duplicate]

I'm using Ubuntu 14.04 and have this in my .bash_profile: export EDITOR=/usr/bin/vim export VISUAL=/usr/bin/vim man respects this setting but info always opens in something else, nano or it's own ...
0
votes
1answer
173 views

Why can't my `date` deal with timezones? [duplicate]

I'm having some weird issues with GNU coreutils date v8.4 (CentOS) that aren't occurring in v8.21 (Ubuntu/Mint). On v8.4, I get the following output (I'm in PST): $ date --version | head -n 1 date ...
2
votes
1answer
572 views

Problem with install command to copy a whole directory

So I have a repo with some of my config files and I'm trying to create a makefile to install them in the homedir. The problem I have is that when I run the following command straight in bash install ...
0
votes
2answers
537 views

Permissions for installing coreutils with pkgsrc on NetBSD

I'm trying to install coreutils on NetBSD 6.1.5 using the pkgsrc system. This is on the default install of 6.1.5. The only change made has been to install zsh and set it as my default shell for users ...
2
votes
1answer
89 views

Where is using @ before a date string for seconds since the epoch documented?

GNU date and touch commands (and presumably others) use @date to define a date string as seconds since the epoch. For example: $ TZ=UTC date -d@10 Thu Jan 1 00:00:10 UTC 1970 I was answering a ...
2
votes
3answers
446 views

When was a file last opened?

How do I determine, when a file was last opened? I've looked at man ls (using GNU coreutils 8.22) and I don't see anything about this timestamp.
8
votes
2answers
979 views

sort by hex value

Using coreutils sort, how can I sort numerically by a hexadecimal value (field)? I was expecting something along the lines of sort -k3,3x file_to_sort however, such an x does not exist. Edit: ...
0
votes
2answers
83 views

Where can I view a changelog for the sort command

I need to find sort's version when the -V flag was introduced. But I am finding myself some hard time finding the changelog for this command. Where can I view it?
1
vote
2answers
140 views

numfmt invalid suffix input

I am using numfmt to convert a remote file's Content-Length from bytes to IEC format, i.e. 21M $ curl -sI http://jruby.org.s3.amazonaws.com/downloads/1.7.12/jruby-bin-1.7.12.tar.gz|grep Length|cut ...
1
vote
1answer
70 views

“install” command as script

I'm working on a heavily modified Linux based OS targeted for a really specific environment - easy-to-use NAS systems. It does not provide any GUI, apart from a web interface, but it at least has SSH. ...
8
votes
2answers
1k 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 ...
30
votes
3answers
2k views

What is the `[` program that resides in my system's /bin?

I was recently browsing my Fedora's /bin folder and noticed a binary named [. I did try to search the internet for more information on that, but I couldn't find anything useful. Running it through ...
4
votes
2answers
498 views

What does `du - hb` do?

With du -bh I think I get the apparent size in human readable format: # du -bh 295K ./test However, I would expect the same from du -hb, but I get something else: # du -hb 301926 ./test I ...
5
votes
2answers
5k views

Why is dd using direct slower writing to disk than to a file

I am trying to compare aggregate write rates when writing to a file in a GPFS file system, as compared to writing directly to a disk on a system with Red Hat Enterprise Linux Server release 6.4 ...
1
vote
1answer
74 views

Memory-efficient utility to return N first sorted values

I would like to implement a very popular MapReduce example using only existing programs operating in a UNIX way. The problem is to find N most frequent values in an enormous amount of data. The ...
4
votes
2answers
112 views

Off by 1 year error in GNU date?

Right now, 2014-01-06, GNU date 8.4 on CentOS release 6.4, does this: $ date --date "last week" +"%Y-%V" 2013-01 On the other hand, $ date --date "last week" +"%Y-%U" 2013-52 which is just ...
0
votes
2answers
350 views

How can I format the output of stat to contain the null character?

I want to delimit file paths by using the null character (NUL, \0, ...) just like for example find -print0 does. I'm using bash and I tried the following without success: find $1 -print0 > ...
0
votes
1answer
272 views

what does the following command do?

what does the following command do? I have tried to study the linux command but I could not find out what this command does. here is the command: touch finger ; finger touch
2
votes
3answers
8k views

cp --no-target-directory explained

Question: I need a simple example of how to use cp --no-target-directory. I do experience some difficulties in understanding cp --no-target-directory. I do understand the explanation for mv ...
6
votes
2answers
10k views

cp -L vs. cp -H

Problem When copying files with cp -H or cp -L, I get the same results: $ ls -l fileA fileA -> fileB $ cp fileA somewhere/ -H $ ls -l somewhere/ fileA # fileA is a copy of fileB, only ...
2
votes
1answer
57 views

Checking the order of items in a shell environment variable

I am wanting to check that a certain directories always appear after other directories in an environment variable. List items are separated by a colon, as with the PATH variable. This is not simply ...
5
votes
3answers
3k views

convert soft- to hardlinks with cp

The cp command's infopage offers on the option --preserve= the following: links Preserve in the destination files any links between corresponding source files. Note that with -L' ...
3
votes
1answer
504 views

cp --attributes-only documented but not working “now”?

PROBLEM: cp --attributes-only Source Target results in two files unchanged, where the attributes from Source should be copied to Target. Attempts to solve: As I have the 8.13 version of coreutils ...
13
votes
3answers
868 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 ...
10
votes
3answers
10k 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 ...