There are a few things you might want to pay attention to, such as using aliases in bash and storing them in bashrc or in a separate file called bashrc
which will facilitate the execution of commands ..
take a look here for expanding commands into aliases (simple aliases are easy)
You can also look at the use of functions in your code (many bash scripts in the home folder above the link to understand the browsing functions of this site ), which has much better examples ...
Take a look at some pipeline tails in a tail tail output script in another script
The thing with bash is its flexibility, so for example, if something starts to get too messy for bash, you can always write perl / Java any lang and then call it from a bash script, grab its output and do something else .
It is not clear why all the pipes can help in any case:
./example.sh 20 function one starts with 20 In function 2 20 + 10 = 30 Function three returns 10 + 10 = 40
script:
example.sh
#!/bin/bash input=$1; source ./shared.sh one echo "------------------------------------------------" echo "------------------------------------------------" echo "Local function variables global:" echo "Result2: $result2 - Result3: $result3 - value2: $value2 - value1: $value1"
shared.sh
function one() { value1=$input echo "function one starts with $value1" two; } function two() { value2=10; result2=$(expr $value1 + $value2) echo "In function 2 $value1 + $value2 = $result2" three; } function three() { local value3=10; result3=$(expr $value2 + $result2;) echo "Function three returns $value2 + $value3 = $result3" }
I think the pipes you have in mind can be functions, and each function can call each other .. and then you give the script the value that it passes through the functions.
bash is pretty flexible about passing values around, as long as the function called before has a variable called by the next function, can reuse it, or it can be called from the main program
I also separated functions that could be obtained by another script to execute the same functions.
E2A Thanks for the support, I also decided to include this link
http://tldp.org/LDP/abs/html/sample-bashrc.html
There are many useful .bashrc functions that contain many functions that also give some insight into how to simplify many daily recurring commands, such as requiring a connection, an alias can be written to do all of them for you ..