07-23-2010 05:36 AM
I want to know is there any way to export following line to new shell also.
trap 'date "+# %c" | read -s' debug
when i do sh and enter to new shell this trap stop working (there need to run again same)
07-23-2010 05:44 PM
You can export variables but not code. In this case, you could place the line in question into a file that you source (or "include") when spawning a new shell. Thus, any shell could do:
echo "I am born..."
Where '/usr/local/bin/myshtraps' contains the line of code you described. Note that shell's sourcing (reading or including) the material are called with a dot ('.') followed by whitespace and the file name. This adds the code and/or variables to the current environment for its use rather than spawning a new subshell.
07-23-2010 10:41 PM
If it is a single line of command, then you can assing the command to a variable and export the variable.
export MYCMD="echo Today is `date '+%d %m %y'`"
# cat child.sh