Crates.io | o-o |
lib.rs | o-o |
version | 0.5.2 |
source | src |
created_at | 2021-11-23 18:17:34.33566 |
updated_at | 2024-05-12 00:57:36.026994 |
description | Enables commands that assume the standard input and output to read and write to files specified in the command line. |
homepage | https://github.com/tos-kamiya/o-o |
repository | |
max_upload_size | |
id | 486445 |
size | 81,021 |
Enables commands that assume the standard input and output to read and write to files specified in the command line.
Have you ever had trouble with interference between a command-invoking command and redirection?
For example, a command line:
ls *.txt | xargs -I {} head -n 3 {} > {}-head.out
does NOT create *-head.out
file for each of the *.txt
files but creates one file {}-head.out
containing outputs of all head
command executions.
The command o-o
is here to help!
You can now run as follows:
ls *.txt | xargs -I {} o-o - {}-head.out - head -3 {}
The o-o
arguments are the standard input, standard output, and standard error output of the child process, and the subsequent arguments are the command line to start the child process.
If you specify -
as the file name for standard input, etc., it will not be redirected. Putting +
in front of a file name will open the file in append mode.
Run a sub-process and customize how it handles standard I/O.
Usage:
o-o [options] <stdin> <stdout> <stderr> [--] <commandline>...
o-o --help
o-o --version
Options:
<stdin> File served as the standard input. Use `-` for no redirection.
<stdout> File served as the standard output. Use `-` for no redirection, `=` for the same file as the standard input, and `.` for /dev/null.
<stderr> File served as the standard error. Use `-` for no redirection, `=` for the same file as the standard output, and `.` for /dev/null.
Prefix with `+` to append to the file (akin to the `>>` redirection in shell).
-e VAR=VALUE Set environment variables.
--pipe=STR, -p STR String for pipe to connect subprocesses (`|` in shell) [default: `I`].
--separator=STR, -s STR String for separator of command lines (`;` in shell) [default: `J`].
--tempdir-placeholder=STR, -t STR Placeholder string for temporary directory [default: `T`].
--force-overwrite, -F Overwrite the file even if subprocess fails (exit status != 0). Valid only when <stdout> is `=`.
--keep-going, -k Only effective when multiple command lines are chained with the separator. Even if one command line fails, subsequent command lines continue to be executed.
--working-directory=DIR, -d DIR Working directory.
--version, -V Version information.
--help, -h Shows this help message.
Use the cargo command to install.
cargo install o-o
When you know that a particular line of the PDF will contain the information you need, such as the title of a article.
ls *.pdf | rargs o-o - - - pdftotext '{0}' - I head -5 I tail -1
Here,
For each of *.xlsm
files, extract vba source code from it, delete the first 5 lines, and save the code to a file with the same name but with the extension changed to .vba
.
ls *.xlsm | rargs -p '(.*)\.xlsm' o-o - '{1}'.vba - olevba -c '{0}' I sed -e 1,5d
The above executes the following command line when there was a file named foo.xlsm
, for example.
olevba -c foo.xlsm | sed -e 1,5d > foo.vba
Here,
Extract the audio from the video file amovie.webm
, save it to a temporary audio file, and then extract text from the temporary audio file.
The temporary file is created on a temporary directory and deleted when the process is finished.
o-o - - - ffmpeg -i amovie.webm T/tmp.wav J whisper T/tmp.wav --model=medium
The above command line is similar to the following command line, except for creating a temporary directory.
ffmpeg -i amovie.webm tmp.wav ; whisper tmp.wav --model=medium
Here,
MIT/Apache-2.0