LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-03-2007, 12:45 PM   #1
BlueSpirit
Member
 
Registered: Jun 2006
Distribution: Slackware
Posts: 144

Rep: Reputation: 15
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
 
Old 06-03-2007, 01:44 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
 
Old 06-04-2007, 09:30 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,307

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
consider sed-awk for $row/ $column processing
 
Old 06-04-2007, 12:22 PM   #4
elsheikhmh
Member
 
Registered: Aug 2004
Location: Cairo, Egypt
Distribution: Slackware
Posts: 101

Rep: Reputation: 15
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
sed script to read only columns 4 to 6 in output database cranium2004 Programming 10 02-28-2006 07:20 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
issues with mirc script accessing our php script dtra Linux - Software 2 07-02-2005 04:30 PM
Accessing Shell variable in awk script dileepkk Linux - General 1 10-07-2004 07:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration