LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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-16-2008, 12:41 AM   #1
radix_2
LQ Newbie
 
Registered: Dec 2008
Location: Dallas
Distribution: Debian
Posts: 7

Rep: Reputation: 0
Question when "| less" isn't more: reading instructions on Debian CLI


Hello, I was trying to use w3m recently, and typing 'w3m' to begin the program a list of instructions passed by. I attempted to read this list by "w3m | less" but this didn't work. Is there another way to view a list that seems longer than the number of lines on the command line?

Related to this, I like the format and coloring of "ls", how can I preserve the color and format of ls for directories of many files and directories. When usually the (objects?) near the command line would be cut out of view. "ls | less" works, and the man page shows there is a switch to maintain some color, but the format is lost. Is there a way to retain color and format?

Last edited by radix_2; 12-16-2008 at 02:52 AM.
 
Old 12-16-2008, 01:07 AM   #2
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
Perhaps these instructions are sent to standard error? If so you can feed them to less with:

w3m 2>&1 | less
 
Old 12-16-2008, 02:40 AM   #3
radix_2
LQ Newbie
 
Registered: Dec 2008
Location: Dallas
Distribution: Debian
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks

Quote:
Originally Posted by penguiniator View Post
Perhaps these instructions are sent to standard error? If so you can feed them to less with:

w3m 2>&1 | less
Thank, that worked. Where can I learn more about the standard outputs? I can't "man ..." and wikipedia would probably give me less technical info than I want to be useful. Where is best?

What does the 2>&1 string mean?
Does anyone know of a solution to my second question?
 
Old 12-16-2008, 02:58 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
less -R


As for the 2>&1 :
That means redirect stderr (2) to stdout (1).
For details:
man bash
/^REDIRECTION
 
Old 12-16-2008, 03:16 AM   #5
radix_2
LQ Newbie
 
Registered: Dec 2008
Location: Dallas
Distribution: Debian
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for that, I'll look at "man bash" tomorrow evening.

"ls | less -R" didn't do the trick. It looks like it should, from the man page, but it doesn't work on my installation. Should it? Could someone corroborate that this retains color <i>and</i> format? Or just format. For some strange reason, my install doesn't even show color, I remember it working before the reinstall though.
 
Old 12-16-2008, 03:22 AM   #6
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
You can also read about I/O redirection at http://tldp.org/LDP/abs/html/io-redirection.html
 
Old 12-16-2008, 04:33 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by radix_2 View Post
Thanks for that, I'll look at "man bash" tomorrow evening. :)

"ls | less -R" didn't do the trick. It looks like it should, from the man page, but it doesn't work on my installation. Should it? Could someone corroborate that this retains color <i>and</i> format? Or just format. For some strange reason, my install doesn't even show color, I remember it working before the reinstall though.
As for the format - the problem isn't with less, but with ls.

ls "knows" whether it writes to stdout, or to a pipe, and
modifies its output accordingly. You can influence the result
a bit, by doing 'ls -C | less -R', but you may find that it
still doesn't *quite* resemble what you're expecting.



Cheers,
Tink
 
Old 12-16-2008, 08:42 PM   #8
radix_2
LQ Newbie
 
Registered: Dec 2008
Location: Dallas
Distribution: Debian
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
but you may find that it
still doesn't *quite* resemble what you're expecting.
No, thanks, now I know how to retain color and how to retain format. Format is more important.

What is the standard way to list a directory with a lot of files? Is it "ls -C | less"?

Thanks both of you. I already have my answer, I just want to know what is standard. I'm trying to live in the command line.

Last edited by radix_2; 12-16-2008 at 11:28 PM.
 
Old 12-17-2008, 11:36 AM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by radix_2 View Post
What is the standard way to list a directory with a lot of files? Is it "ls -C | less"?

Thanks both of you. I already have my answer, I just want to know what is standard. I'm trying to live in the command line.
Heh. How long is a piece of string? :}

I'll seldomly look at all files in a directory, and
the directories (or directory structures, for that
matter) commonly aren't that full. I'm trying to keep
my stuff organised in a structured manner, which
makes maintenance easier and listings faster.

I've *never* used the -C (or -x) switches to ls in any
practical manner. Often I'll use -l, commonly combined
with a sort-switch (by size, by modified time), and I
always use --time-style=long-iso (in fact ls on my
systems is an alias for that)
 
  


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
I Cannot Get My Internet Connection to Work Under the "testing" version of Debian Zerimas Linux - Newbie 2 09-27-2008 01:29 AM
Debian apache2 phpbb doesn't work, always displays "it works" 1veedo Linux - Server 6 03-22-2008 10:26 PM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 02:34 PM
Will /etc/fstab device "lines" from Mandrake work in Debian? gpfromnc Debian 12 04-27-2006 04:13 PM
An observation about "it doesn't work on Debian but it works on Red Hat..." sundialsvcs Linux - General 2 03-12-2006 07:31 PM


All times are GMT -5. The time now is 12:32 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration