I'm trying to put a flag that can sort or shuffle the output, but I could only do that in code and intended it to work when I put the flag on the command to run the file, for example ./bash.sh -r .
I'm trying to put a flag that can sort or shuffle the output, but I could only do that in code and intended it to work when I put the flag on the command to run the file, for example ./bash.sh -r .
A small example:
#!/bin/bash
case $1 in ## definir o pósprocessador
-r) pp="shuf" ;; # -r shuffle
-s) pp="sort" ;; # -s sort
*) pp="cat -n" ;; # default numera linhas
esac
function proc(){
ls /bin ## ... produzir um output
}
proc | $pp