Is it possible to add stdout to the left side of each output (and stderr if possible) when I command Bash Bash Script?
I would like to do something like this:
#! / Bin / bash Echo installation: some echo "= need to be predefined =" ## INSERT MAGICAL LEFT SPACES COMMAND ## apt-get install -q -y prerequisite ## Other conceptual castling space command to leave here ## echo "= & Gt; Installing Preceded # 2" # padding again ... wget http: /abab/lostzilla.tar.gz tar vzxf lostzilla.tar.gz CD lostzilla-1.01 / Configure & amp; Amp; Install # ... end of padding ... finished echo Any ideas?
Edit: Echo commands have been added to the echo command, otherwise they will not be padded.
Yes, you can quote them for simple things:
echo => Install Precursit1 ' for complex things and piping output through sed :
tar vzxf lostzilla .tar.gz 2 & gt; & Amp; 1 | Sd / ^ / / ' 2 & gt; And puts 1 stdout and stderr on the stdout stream and at sed , replaces the line marker of each space with three positions.
This will work on something like wget which I do not believe in all kinds of cursor manipulation.
The example shown here:
pax> Ls -1 p * phase1.py phase 1 .sh phase 2/2 step step. Prsh. Primes.exe primes.sh primes.stat pax & gt; LS-1P * | Sed 's / ^ / /' phase1.py Phase 1.sh Phase 2 / Phase 2.sh primes.c primes.exe primes.sh primes.stat I used one The trick past is to ensure that the scripts themselves take care of the indentation:
#! / Bin / bash if [["$ {DONT_EVER_SET_THIS_VAR}" = ""]]; Then export DONT_EVER_SET_THIS_VAR = except_for_here $ 0 | Sed 's / ^ / /' exit fi ls -1 p * to run this script again with sed again with indentation It will run if it is not doing this already. In this way, you do not have to worry about changing all your output statements, there is a bit of a hack, I know, but I just want to do what is needed for quick and dirty shell scripts.
Comments
Post a Comment