How import $COLUMNS from set into script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How import $COLUMNS from set into script
# 1  
Old 06-02-2009
How import $COLUMNS from set into script

im trying to do this inside a bash script;

for ((a=$COLUMNS;a>0;a--))
do
printf "="
done
printf "\n"

With it i want to display an "equals" line as long as de curent shell window.
but i can't get the $COLUMNS variable from the set enviroment.

Some help please.

Last edited by Tártaro; 06-02-2009 at 06:10 PM..
# 2  
Old 06-02-2009
try this:

xyz=`echo $COLUMNS`
for ((a=$xyz;a>0;a--))
do
printf "="
printf "\n"
done
# 3  
Old 06-02-2009
Thanks but this dosen't work.The problem is i can't get $COLUMNS from the enviroment.

-----Post Update-----

i found myself the solution;

for ((a=$(tput cols);a>0;a--))
do
printf "="
done
printf "\n"

bye

Last edited by Tártaro; 06-02-2009 at 06:09 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Import 2 columns from 8 .csv files into pandas df (side by side) and write a new csv

I have 8 .csv files with 16 columns and "n" rows with no Header. I want to parse each of these .csv and get column and put the data into a new.csv. Once this is done, the new.csv should have 16 columns (2 from each input.csv) and "n" rows. Now, I want to just take the average of Column from... (3 Replies)
Discussion started by: Zam_1234
3 Replies

2. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

3. UNIX for Dummies Questions & Answers

How to import a variable Used in Another Korn Shell Script?

Hi I am using two shell scripts which are running on the system simultaneously. And in one of the script i am exporting an Integer Variable. Now i want to use the variable in another script. But i cannot run the first script in the second as the first script has many other functions which... (3 Replies)
Discussion started by: Ajesh
3 Replies

4. Shell Programming and Scripting

Script to set columns to days in month

I am trying to figure out how to assign columns of a text file to the day of the month. The end result will be a way to determine when each day (column) is populated with data. The data file are in the format of: M1Y2012 x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x... (8 Replies)
Discussion started by: ncwxpanther
8 Replies

5. Shell Programming and Scripting

How can I do one liner import multiple custom .pm files in my perl script?

I am new for Perl I want to ask one question. I have around 50 custom packages which i am using in my Perl script. I want to import all .pm packages in my Perl script in an easy way. Right now i have to import each package individually. So Is there any way to do so?? Right Now i am doing like: ... (1 Reply)
Discussion started by: Navrattan Bansa
1 Replies

6. Shell Programming and Scripting

Shell script for an db import process

Hello, I would like a to have an script that would accept variables for "foruser" and "touser" during an db import.. I am pasting an sample script below... The "and" in the below script needs to changed..to a correct syntax for i in `cat /tmp/from` and for j in `cat /tmp/to` do {... (2 Replies)
Discussion started by: jjoy
2 Replies

7. Programming

How to set stty row and columns of the terminal through C program

Hi, I'm have a big problem with one of the C programs that I'm developping. actually, I'm trying to monitor the users' session in solaris. therefore, I have used the source code of the unix "script" command. but the problem is that, when i run that program, the stty settings are lost: speed... (4 Replies)
Discussion started by: saad26
4 Replies

8. Shell Programming and Scripting

Data Import perl script

Hi, I have a requirement for creating a Perl Script which will perform Data Import process in an automated way and I am elaborating herewith : Section 1 ) - use the following command line format : "./import.pl -h hostname -p port -f datafile.txt" Section 2) datafile.txt will... (3 Replies)
Discussion started by: scott_apc
3 Replies

9. UNIX for Advanced & Expert Users

Pearl script to automate SSL certificate import

Hello, I want to automate the process of importing a SSL certificate name *.cer to cacerts through perl script. both the certificates belong to same folder. The usual way of doing it is by executing the below command which imports the key name certnew.cer to cacerts in the same folder. ... (4 Replies)
Discussion started by: m_kk
4 Replies
Login or Register to Ask a Question