Linux/moreutils: Difference between revisions
< Linux
(Created page with "= 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 int...") |
No edit summary |
||
Line 2: | Line 2: | ||
== chronic == | == chronic == | ||
chronic - runs a command quietly unless it fail | |||
== combine == | == combine == | ||
combine - combine sets of lines from two files using boolean operations | |||
combine file1 and file2 | |||
combine file1 not file2 | |||
combine file1 or file2 | |||
... | |||
combine combines the lines in two files. Depending on the boolean operation specified, the contents will be combined in different ways | |||
== errorno == | == errorno == | ||
Line 99: | Line 110: | ||
== vidir == | == vidir == | ||
vidir - edit directories and filenames | |||
== vipe == | == vipe == | ||
vipe - edit pipe | |||
vipe allows you to run your editor in the middle of a unix pipeline and edit the data that is being piped between programs. Your editor will have the full data being piped from command1 loaded into it, and when you close it, that data will be piped into command2. | |||
== zrun == | == zrun == | ||
zrun - automatically uncompress arguments to command | |||
= keywords == | = keywords == |
Latest revision as of 22:36, 28 August 2024
moreutils
chronic
chronic - runs a command quietly unless it fail
combine
combine - combine sets of lines from two files using boolean operations
combine file1 and file2 combine file1 not file2 combine file1 or file2 ...
combine combines the lines in two files. Depending on the boolean operation specified, the contents will be combined in different ways
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
vidir
vidir - edit directories and filenames
vipe
vipe - edit pipe
vipe allows you to run your editor in the middle of a unix pipeline and edit the data that is being piped between programs. Your editor will have the full data being piped from command1 loaded into it, and when you close it, that data will be piped into command2.
zrun
zrun - automatically uncompress arguments to command