Linux/moreutils
< Linux
moreutils
chronic
combine
errorno
errno looks up errno macro names, errno codes, and the corresponding descriptions. For example, if given ENOENT on a Linux system, it prints out the code 2 and the description "No such file or directory". If given the code 2, it prints ENOENT and the same description.
# errno 0
# errno 1 EPERM 1 Operation not permitted
# errno 2 ENOENT 2 No such file or directory
ifdata
ifdata - get network interface info without parsing ifconfig outpu
ifdata -p enp1s0f0 10.10.10.100 255.255.255.0 10.10.10.255 150
ifne
ifne - Run command if the standard input is not empty
Example:
find . -name core | ifne mail -s "Core files found" root
isutf8
isutf8 checks whether files are syntactically valid UTF-8. Input is either files named on the command line, or the standard input. Notices about files with invalid UTF-8 are printed to standard output.
lckdo
lckdo runs a program with a lock held, in order to prevent multiple processes from running in parallel. Use just like nice or nohup.
Now that util-linux contains a similar command named flock, lckdo is deprecated, and will be removed from some future version of moreutils
If the lock was successfully acquired, the return value is that of the program invoked by lckdo. If the lock couldn't be acquired, EX_TEMPFAIL is returned. If there was a problem opening/creating or locking the lock file, EX_CANTCREAT or EX_OSERR will be returned.
Example:
$ lckdo .testlock sleep 100 &
$ lckdo .testlock sleep 100 lckdo: lockfile `.testlock' is already locked
$ echo $? 75
$ errno 75 EOVERFLOW 75 Value too large for defined data type
errno doesn't know what EX_TEMPFAIL is??
$ errno -s EX_TEMPFAIL (nothing returned)
mispipe
mispipe - pipe two commands, returning the exit status of the first
mispipe ["command1"] ["command2"]
The exit status of the first command. If the process terminated abnormally (due to a signal), 128 will be added to its exit status.
parallel
parallel - run programs in parallel
Example:
parallel sh -c "echo hi; sleep 2; echo bye" -- 1 2 3
This runs three subshells that each print a message, delay, and print another message. If your system has multiple CPUs, parallel will run some of the jobs in parallel, which should be clear from the order the messages are output.
pee
pee - tee standard input to pipes
pee is like tee but for pipes. Each command is run and fed a copy of the standard input. The output of all commands is sent to stdout.
Note that while this is similar to tee, a copy of the input is not sent to stdout, like tee does. If that is desired, use pee cat ...
sponge
sponge - soak up standard input and write to a file
sed '...' file | grep '...' | sponge [-a] file
sponge reads standard input and writes it out to the specified file. Unlike a shell redirect, sponge soaks up all its input before writing the output file. This allow constructing pipelines that read from and write to the same file.
ts
ts adds a timestamp to the beginning of each line of input.
See Linux/ts