Hi
I want to export the result from a awk command into a variable in a bash
script. How do I do that?
PS: I do not want to have to create a file and then read from it to
load the variable. I tried redirection, but no luck, not enough experience.
(I have read the awk manual and fiddled quite a bit.
I also looked at some existing scripts, no inspiration so far.
Will have to learn by example am afraid. thanks)
I call my script with ./myscript.sh --*.txt
(In practice I want to get a substr of the argument passed to the script)
There must be zillion way of doing it... but fow now I am trying with awk.
Code:
#!/bin/bash
myvar=$1
echo "myvar is $myvar"
myshortvar=""
gawk 'BEGIN { print substr("'$myvar'",3) }'
#this above works fine. Now how do I return the result to myshortvar?
#ls -l $myvar
#mydir=`pwd`
#df -hl $mydir