pd: Linux pipeline debug - preserves intermediate outputs in a linux terminal pipeline command #741
Labels
CLI-UX
Command Line Interface user experience and best practices
linux
Linux notes tools links
shell-script
shell scripting in Bash, ZSH, POSIX etc
TITLE: ketancmaheshwari/pd: Linux pipeline debug
DESCRIPTION: "pd.sh : preserve intermediate outputs in a Linux terminal pipeline command
In a typical Linux terminal piped command, the intermediate outputs (and errors, if any) are lost. This tool preserves intermediate outputs and errors for inspection and/or debugging. It decomposes each stage of the pipeline as a separate command and places it in a shell script. It then runs the script with user permission. It prints the exit status of the commands and saves standard output and error in numbered files inside a created dir with a random name.
Usage Examples:
In a debugging scenario, a quick way to run this is to use !!, the bash shorthand to print last command run, for instance:
But this is same as tee
Yes. Except that it preserves standard errors of the intermediate commands (in addition to stdout) and is relatively easy to read compared to interjecting tee commands at each stage of the pipeline.
Known Limitations
No way to escape the shell expansion in the quick !! way. One has to manually escape the $ using \, for instance in the following pipeline the awk will run without $1 because bash expansion eats $1:
URL: https://github.com/ketancmaheshwari/pd
Suggested labels
The text was updated successfully, but these errors were encountered: