Bash: random notes

When you are running bash script and the script is having some variable, how do you access the value of the variable after bash script finishes?

  • The script runs in its own sub shell, so the variables dont get exported to your env. But when you put the variable value to lets say .bash_profile file or any other file really and then you source it, then you can access the variable that way.

You are feeding lots of arguments from the command line to your bash script. How do you process them one at a time.

  • you can use shift command within bash script to go through the arguments.

Investigate use of xargs together with find command when you have lots of directories and files to go through.

  • still checking on solution

What does exec directive do within bash script?

  • prevents commands to create new sub shell.