Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-25-2011, 07:36 PM   #1
LQ Newbie
Registered: Jun 2005
Posts: 22

Rep: Reputation: 1
less displays binary but cat displays ascii?

I'm running the following command
./ &> log
After some time..
file log
log: data
The following commands display binary
less log
vim log
cat log | less
cat log
displays the ascii text properly.

Why? Is it possible to use less to view the log?


Last edited by ahtoot; 01-25-2011 at 07:40 PM.
Old 01-25-2011, 08:14 PM   #2
Registered: Jul 2007
Location: Chicago Illinois
Distribution: SLES 10 SP2/SP3, SLES 11 SP1, OpenSUSE, Sabayon, Gentoo, Fedora 14, RHEL 3/4/5/6
Posts: 98
Blog Entries: 3

Rep: Reputation: 23
Try doing this instead:

./ > log &
I could be wrong, but I'm thinking the above command will start the script and output to log, and then put the entire process in the background.

If the script really is producing binary data, perhaps there is a special tool to read the log file. The other possibility is to use the `strings` command on the log file. That should parse out the ascii entries in the "log" file.


Last edited by binary_pearl; 01-25-2011 at 08:16 PM. Reason: new idea just came to me
Old 01-25-2011, 08:24 PM   #3
LQ Newbie
Registered: Jun 2005
Posts: 22

Original Poster
Rep: Reputation: 1
Figured it out, I had pages of binary data followed by ascii text.

cat displayed the ascii tail of the file, less started with the binary head.
1 members found this post helpful.
Old 01-25-2011, 08:38 PM   #4
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Well the output of the command file says it.
file log
log: data
I think the file contains escape sequences which hinders "less" to display it properly.
You could use mc (midnight commander) to view the file in hex mode.
Or use:
mcview log
for the command line (gives you a ncurses interface).


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
displays :0, :1? fdelval Linux - Desktop 4 12-04-2010 07:47 AM
two displays giraf Ubuntu 1 08-07-2009 11:45 AM
cat /proc/version - displays wrong version babu198649 Linux - Newbie 2 11-10-2008 04:10 AM
Dual monitors, separate X displays; want firefox in both displays bforbes Linux - Desktop 7 10-15-2008 09:26 PM
ls -d [a-z]* displays same as ls -d [A-Z]* trrose Linux - Newbie 10 09-03-2008 08:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:38 PM.

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