Suppose I have a lot scripts: 1.sh,2.sh 3.sh, ..., n.sh, and I want to use them this way:
./1.sh | 2.sh | 3.sh | ... | n.sh
I'd like to share variables from 1.sh to the others.
I tried to export the variables. The problem is: I don't want them to exist after the last completes. It would be easy to make n.sh to erase them, but it sounds a workaround to me.
There are a lot of answers with solutions here on Stack Overflow, but neither of them goes round to me.
All in all, I'm asking if there is a way of constructing variables that work only for a sequence of commands with pipes.
Is there a way of doing this without workarounds?

