LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-17-2012, 11:32 AM   #1
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Rep: Reputation: Disabled
long command line is wrapped at the beginning of the same line


I tried to change COLUMNS and added "export COLUMNS=250"
in my .bash_profile.
but after re-login, suppose it will pick up the updated COLUMNS variable, but it didn't. I did source the .bash_profile again, then the variable is updated. But when I use "set" command, it is still the old value. I don't know where 65 is set. and when I resize the terminal window, this value keeps changing. Can somebody explain this to me?
Thanks,
after re-login
[ipbx@lab33 ~]$ printenv COLUMNS
65
[ipbx@lab33 ~]$ echo $COUMNS

[ipbx@lab33 ~]$ echo $COLUMNS
65
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=65
[ipbx@lab33 ~]$ . ~/.bash_profile
[ipbx@lab33 ~]$ echo $COLUMNS
250
[ipbx@lab33 ~]$ printenv COLUMNS
250
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=65
_=COLUMNS
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=65

[ipbx@lab33 ~]$ set COLUMNS=250
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=94
_=COLUMNS=250
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=94
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=94
[ipbx@lab33 ~]$ set|grep COLUMNS
COLUMNS=126
 
Old 12-17-2012, 12:03 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 285Reputation: 285Reputation: 285
If you're using bash shell, append this variable in .bashrc or in .profile, as:
Code:
COLUMNS=250; export COLUMNS
And, also add following line at the end of your .profile:
Code:
source .bashrc
Then once logout and login to check it again, as:
Code:
echo $COLUMNS
env | grep COLUMNS
Or
printenv | grep COLUMNS
 
Old 12-17-2012, 12:09 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
There's no point in setting this variable, it is (re)set by bash itself. From the man page:
Quote:
COLUMNS
Used by the select builtin command to determine the terminal
width when printing selection lists. Automatically set upon
receipt of a SIGWINCH.
Try resizing (width) your xterm (do an echo $COLUMNS before and after).

Did you try this to solve the wrapping problem or did it introduce it?

Last edited by druuna; 12-17-2012 at 12:11 PM.
 
Old 12-17-2012, 02:45 PM   #4
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,159
Blog Entries: 4

Rep: Reputation: 760Reputation: 760Reputation: 760Reputation: 760Reputation: 760Reputation: 760Reputation: 760
Code:
shopt -s checkwinsize
in .bashrc should help. Don't forget log out|in.
 
Old 12-17-2012, 04:45 PM   #5
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
to Drunna's questions,
I was trying to solve the wrapping problem by resetting "COLUMNS". and I am using bash.
What does "shopt -s checkwinsize" do? WILL that solve the wrapping problem?
 
Old 12-18-2012, 12:20 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Quote:
Originally Posted by lwang3rock View Post
to Drunna's questions,
I was trying to solve the wrapping problem by resetting "COLUMNS". and I am using bash.
The cause of the wrapping problem might be your prompt (PS1). Did you try to alter it?
 
Old 12-19-2012, 10:31 AM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I believe there's some miscommunication at work here. I, and probably most of the others, don't understand what the "wrapping" trouble actually is, and why you think you have to mess with the COLUMNS variable to fix it.

Could you please explain exactly what your problem is, in detail?

And please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.

edit: After reading the title again a couple of times, I think druuna may be right, and you have a mis-configured prompt. If there are unprotected non-printing characters involved, you often get behavior like lines wrapping back upon themselves.

So if you've changed something in your PS1 variable, please post it (in code tags, naturally).

Last edited by David the H.; 12-19-2012 at 10:36 AM. Reason: as stated
 
Old 12-27-2012, 06:43 PM   #8
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
Sorry about the confusion. At first, I thought that changing COLUMNS may solve the problem. But it didn't.
I didn't change PS1. Here is my PS1 value.
Code:
lwang@california:~/project/aurra$ set|grep PS1
PS1='\u@\h:\w\$ '
 
Old 12-27-2012, 07:24 PM   #9
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
for example,
Code:
19.ng@california:~/project/aurra$ scp packages/intraswitch-SP13.0.3-sp-linux.tgz lwang@192.84.
19 should be after 84., but it goes at the beginning of the line.
 
Old 12-28-2012, 02:31 AM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Quote:
Originally Posted by lwang3rock View Post
for example,
Code:
19.ng@california:~/project/aurra$ scp packages/intraswitch-SP13.0.3-sp-linux.tgz lwang@192.84.
19 should be after 84., but it goes at the beginning of the line.
Did you have a look at Habitual's reply (p#4):

Set shopt -s checkwinsize in your /etc/bash.bashrc (or similar for your distro) to make it global or put it in ~/.bashrc to make it local.
 
Old 12-28-2012, 12:27 PM   #11
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
I tried "shopt -s checkwinsize", the wrapping didn't work immediately. After I re-size the window to smaller size, the long command was wrapped to the next line afterwards.
I looked at another shell, checkwinsize was on by default. So I am not sure if "shopt -s checkwinsize" helped.
I am going to add this shopt to my .bashrc anyway to see if I will run into the same problem again.
Thanks for help.
 
  


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
[SOLVED] Cursor does not move to the bottom line and overwrite to same line on command line mesuutt Linux - Newbie 3 02-25-2012 08:04 AM
How long can my command-line be? Angus Linux - General 17 11-24-2009 08:31 AM
Perl question: delete line from text file with duplicate match at beginning of line mrealty Programming 7 04-01-2009 06:46 PM
Konsole wraps up long command to the same line rsashok Red Hat 2 01-30-2007 07:41 PM


All times are GMT -5. The time now is 04:58 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration