LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shell - Accessing COLUMNS in a script!? (https://www.linuxquestions.org/questions/programming-9/shell-accessing-columns-in-a-script-558839/)

BlueSpirit 06-03-2007 12:45 PM

Shell - Accessing COLUMNS in a script!?
 
Hello,

I would like to know : How can we be able to use the COLUMNS variable in a script???

I have done a script wich needs $COLUMNS in order to print a correct output.

Now what I hace is COLUMNSV=$3

So when i call thje function, i use

Code:

fkldrb 100 0.01 $COLUMNS
But it is not really useful...

How can I have access to it in the script?

Thank you,

BlueSpirit

jlinkels 06-03-2007 01:44 PM

Quote:

Originally Posted by BlueSpirit
Now what I hace is COLUMNSV=$3

What is a typo in this sentence and what isn't?

Quote:

Originally Posted by BlueSpirit
Code:
fkldrb 100 0.01 $COLUMNS

What is not working well here?

Quote:

Originally Posted by BlueSpirit
Code:
fkldrb 100 0.01 $COLUMNS

What program is fkldrb and what is it supposed to do?

In a script the $LINES and $COLUMNS environment variables cannot be retrieved as they are not exported in the shell.

Use
export LINES
in the shell before you call your program (not in a script). You can add it to your .profile if you want to have them set always.

jlinkels

schneidz 06-04-2007 09:30 AM

consider sed-awk for $row/ $column processing

elsheikhmh 06-04-2007 12:22 PM

use export to set the value of the variable COLUMNS. then use $COLUMNS to pass the value to your program
example:
Code:

mustafa@LILPC ~$ export COLUMNS=3
mustafa@LILPC ~$ seq 1 $COLUMNS
1
2
3
mustafa@LILPC ~$

Quote:

COLUMNSV=$3
what is COLUMNSV? and what is $3?


All times are GMT -5. The time now is 02:10 AM.