davomarcus
Technical User
Basically I want to take the output of the line below and execute it without writing the line into a file before hand or after...just on one command line.
For example, if I type one line at a time into the command line:
setenv dav 1
echo $dav produces the correct output in the shell a "1"
now:
in my directory I have another direcotry called:
something like XXXXXXXXXXXX999XXXX.
if I:
ls | awk '{print "setenv dav " substr($1,13,3)}'
returns into the shell:
setenv dav 999
the output of the awk works fine and delviers the desired value into the shell *but* it does not change the environment variable "dav" which was previously set to 1.
I also tried this variation and it does not work:
ls | awk '{print "setenv dav " substr($1,13,3)}' | tcsh
Why is this so difficult?
If I try something like this:
ls | awk '{system ( "setenv dav" $1 )}'
the "setenv" or "setenv dav" call is not recognized when it runs through the system call running though awk. If I change "setenv dav" to something like "cd /tmp" it will work, the system call works fine.
I am going nuts here and am to "fawk" it all when it comes to awk! (Don't mean to offend...just very frustrated here).
I would really appreciate some expert help.
I am running fedora core 3 in tcsh.
I am probably missing something very basic.
Thanks Much,
DavoMarcus
For example, if I type one line at a time into the command line:
setenv dav 1
echo $dav produces the correct output in the shell a "1"
now:
in my directory I have another direcotry called:
something like XXXXXXXXXXXX999XXXX.
if I:
ls | awk '{print "setenv dav " substr($1,13,3)}'
returns into the shell:
setenv dav 999
the output of the awk works fine and delviers the desired value into the shell *but* it does not change the environment variable "dav" which was previously set to 1.
I also tried this variation and it does not work:
ls | awk '{print "setenv dav " substr($1,13,3)}' | tcsh
Why is this so difficult?
If I try something like this:
ls | awk '{system ( "setenv dav" $1 )}'
the "setenv" or "setenv dav" call is not recognized when it runs through the system call running though awk. If I change "setenv dav" to something like "cd /tmp" it will work, the system call works fine.
I am going nuts here and am to "fawk" it all when it comes to awk! (Don't mean to offend...just very frustrated here).
I would really appreciate some expert help.
I am running fedora core 3 in tcsh.
I am probably missing something very basic.
Thanks Much,
DavoMarcus