Question:
At work, sometimes you have to read old scripts, often there is no markup in them, which increases the time to find the necessary block or problem. Since all this is on a server without a GUI, it is problematic to perform markup using editors.
For example, a simple comparison:
#!/bin/bash
if [[ ${1} == ${2} ]]; then
echo "Параметры идентичны"
else
echo "параметры различаются"
fi
It will be more convenient to read if the indents are set:
#!/bin/bash
if [[ ${1} == ${2} ]]; then
echo "Параметры идентичны"
else
echo "параметры различаются"
fi
Answer:
You can use vim
:
$ vim +"normal! gg=G" +"wq" ./file.bash
Normally executes the command "go to the beginning of the file and format to the end of the file" and exits.