Help answer threads with 0 replies.
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 03-30-2008, 12:36 PM   #1
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
ls > temp has extra characters

I have a series of log files I'd like to scroll through all at once instead of catting or lessing each one. So I'm thinking:

ls -1tc |xargs -l1 cat |less

This gives a bunch of errors like foo.file not found. So I tried to simplify. (I know logging in as root is generally a Bad Thing.)
[root@localhost log]# ls -1tc |tee temp
[root@localhost log]# cat temp
[root@localhost log]# vi temp

[2]+  Stopped                 vi temp
[root@localhost log]# ls -1tc |xargs -l1 cat
cat: temp: No such file or directory
cat: htm/: No such file or directory
cat: dptrace-1.txt: No such file or directory
cat: dptrace-2.1: No such file or directory
cat: dptrace-2.2: No such file or directory
cat: dptrace-2.txt: No such file or directory
So of course cat is failing; the temp file has all these wierd characters. But why does vi show them, and not cat? And why does ls > temp add all those extra characters?

I'm also confused about why the temp file that is just being created shows up during the ls command.

The linux box is RHEL 5.1, but I'm using Putty to ssh in. Putty with XMing is pretty dang useful!

Last edited by djeikyb; 03-30-2008 at 12:38 PM.
Old 03-30-2008, 01:14 PM   #2
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 75
The extra characters are ANSI escape sequences for colors. Perhaps you have an alias for ls to ls --color=always. Try removing this (or setting it to ls --color=auto).
Old 03-30-2008, 01:14 PM   #3
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
I think they're colour codes; you might find that your ls command is actually aliased to ls --color (check with "alias" or "type ls"). To remedy it, try this:
\ls -1tc |tee temp
That should use the original ls command, not its alias. Otherwise, specify the path to ls
/usr/bin/ls -1tc |tee temp
Old 03-30-2008, 02:20 PM   #4
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Original Poster
Rep: Reputation: 33
Yep, ls was aliased to color=always. Now I know why auto is recommended! Thanks guys.


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
tcsh double click text selection - extra characters Kyoseki Linux - Desktop 4 10-17-2006 12:03 AM
sed error message:extra characters after the command wmh830621 Programming 4 08-14-2006 07:13 PM
Extra characters in CuteCom jdupre Linux - Software 0 06-17-2005 07:02 PM
sed error message: extra characters after the command. nano_mag Linux - General 3 05-15-2005 01:00 AM
KDE Konsole adding extra characters Tiyogi Linux - Software 2 04-26-2004 03:21 PM

All times are GMT -5. The time now is 08:24 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