What OFS in Print statement does?
I am new to AWK so i didnt have no idea what OFS means?
Thanks,
Raamc
Code:
>awk 'BEGIN{
while ( i < 5 )
{
i++
$i=OFS="*"
print
$i=""
}
}'
Hi , you don“t need a input file , this awk has only a begin part (execuded once before any input is read).
Then we can change dinamically the number of fields ($i), and assign value to it.
Ex:
Code:
> awk 'BEGIN{$5="x";print}'
x
As you see , with this litle trick we order awk to print the 5th field with value "x".
OFS is the Output Field Splitting ,by default its value is a blank space, we didn't change it so the output of the previous statement is four blanks (because in five fields we have 4 field separators).
Next step:
Code:
> awk 'BEGIN{$5=OFS="x";print}'
xxxxx
Here we changed the OFS to "x" so the awk prints four OFS "xxxx" and the 5th field "x".
Finally we have to set the $i variable to null cause ,if we don't do that , the variable $i will have value "*" at i postion , like in this example:
Code:
> awk 'BEGIN{ while ( i < 5 )
{
i++
OFS="*"
$i="o"
print
}
}'
o
o*o
o*o*o
o*o*o*o
o*o*o*o*o
Hi All, when I executed the query in normal unix mode, the output is
expected. if I executed the query using shell script, I am not getting the result. not sure whether I need to use dbms_output.put_line or echo.
dbms_output.put_line("COUNTRY_CODE"||" "||"SUB_TYPE"||" ... (3 Replies)
Hi,
I want to print 1 to 10 or upto any number sequentially with space in a single line. Like,
1 2 3 4 5 6 7 ......
In shell script only.. Can anyone plz help me.
Thanks: (14 Replies)
pointsb=`awk -v a2="$a2" -v b2="$b2" -v c2="$c2" -v yb="$yb" -v yc="$yc" \
'BEGIN { for (y=yc; y<=yb; y++) { x = a2*y*y+b2*y+c2; print x, y }; }'`
I am learning shell script. I was reading a script and got confused in this line.
I understood that awk is allowing to assign the variable.
But... (10 Replies)
I have a file with similar line like below
/u13/orabkup/u13/orabkup/abcd/arc82.123
Now I need to have only u13/orabkup/abcd/arc82.123 rather than /u13/orabkup/u13/orabkup/abcd/arc82.123
Kindly help me to print /u13/orabkup/ only once and the file name abcd/arc82.123..
Thanks & Regards... (1 Reply)
how to create a half-triangle like this
and that will accept an input from the user, Dimension of the triangle will be based on the users input.
example:
enter the dimension: 5
*****
-****
--***
---**
----*
thankyou (3 Replies)
I found that
echo "aaa" | awk '{print ",\\";}'
works, and it will give "\".
but
ddd=`echo "aaa" | awk '{print ",\\";}'`; echo $ddd
will not work.
Could anyone tell me why? thank you. (8 Replies)
Hi :)
I am learning shell scripting, I need help,
I would like to have a script that produces pascal's triangle as shown in the picture
http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Pascal%27s_triangle_5.svg/250px-Pascal%27s_triangle_5.svg.png
plz, help it's urgent
thanks in... (1 Reply)
Hi
I want to write a shell script to print only those words from a file whose beginning
and last character are same.
Please help.
Thanks,
vini (5 Replies)