In order to see the files with the lines chopped (i.e. line wrapping.) But it's not working, the lines aren't being wrapped and I need to scroll horizontally to see the entire line. What can I do?
$COLUMNS is set to the terminal width by the shell. You can try other widths depending on your needs, of course. If you're running this in a script you may not have either $COLUMNS or $LINES defined - in that case you can use tput lines instead.
If you really want lines chopped (in this example, keep the first 80 chars) instead do this:
"chop" means truncate (discard remainder of line) not fold (put remainder at start of next line).
The documented behaviour of the -S option to less is to do the opposite of what you describe.
-S or --chop-long-lines
Causes lines longer than the screen width to be chopped rather
than folded. That is, the remainder of a long line is simply
discarded. The default is to fold long lines; that is, display
the remainder on the next line.
(I think of -S as meaning "Scroll Sideways to See end of line")
Try omitting the -S option.
$ wc longlines.txt
9 128 726 longlines.txt
$ less longlines.txt
WHAN that Aprille with his shoures soote The droghte of Marche hath perced to th
e roote,
And bathed every veyne in swich licour, Of which vertu engendred is the flour;
Whan Zephirus eek with his swete breeth Inspired hath in every holt and heeth
The tendre croppes, and the yonge sonne Hath in the Ram his halfe cours y-ronne,
And smale fowles maken melodye, That slepen al the night with open ye,
So priketh hem nature in hir corages: Than longen folk to goon on pilgrimages,
And palmers for to seken straunge strondes, To ferne halwes, couthe in sondry lo
ndes;
And specially, from every shires ende Of Engelond, to Caunterbury they wende,
The holy blisful martir for to seke, That hem hath holpen, whan that they were se
ke.
longlines.txt (END)
$ less -S longlines.txt
WHAN that Aprille with his shoures soote The droghte of Marche hath perced to th
And bathed every veyne in swich licour, Of which vertu engendred is the flour;
Whan Zephirus eek with his swete breeth Inspired hath in every holt and heeth
The tendre croppes, and the yonge sonne Hath in the Ram his halfe cours y-ronne,
And smale fowles maken melodye, That slepen al the night with open ye,
So priketh hem nature in hir corages: Than longen folk to goon on pilgrimages,
And palmers for to seken straunge strondes, To ferne halwes, couthe in sondry lo
And specially, from every shires ende Of Engelond, to Caunterbury they wende,
The holy blisful martir for to seke, That hem hath holpen, whan that they were s
longlines.txt (END)
Try this:
$COLUMNS
is set to the terminal width by the shell. You can try other widths depending on your needs, of course. If you're running this in a script you may not have either$COLUMNS
or$LINES
defined - in that case you can usetput lines
instead.If you really want lines chopped (in this example, keep the first 80 chars) instead do this:
"chop" means truncate (discard remainder of line) not fold (put remainder at start of next line).
The documented behaviour of the -S option to less is to do the opposite of what you describe.
(I think of
-S
as meaning "Scroll Sideways to See end of line")Try omitting the -S option.