LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 03-30-2008, 12:36 PM   #1
djeikyb
Member
 
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.)
Code:
[root@localhost log]# ls -1tc |tee temp
temp
htm/
dptrace-1.txt
dptrace-2.1
dptrace-2.2
dptrace-2.txt
[root@localhost log]# cat temp
temp
htm/
dptrace-1.txt
dptrace-2.1
dptrace-2.2
dptrace-2.txt
[root@localhost log]# vi temp
^[[00m^[[00mtemp^[[00m
^[[00;34mhtm^[[00m/
^[[00mdptrace-1.txt^[[00m
^[[00mdptrace-2.1^[[00m
^[[00mdptrace-2.2^[[00m
^[[00mdptrace-2.txt^[[00m

[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
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
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
pwc101
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:
Code:
\ls -1tc |tee temp
That should use the original ls command, not its alias. Otherwise, specify the path to ls
Code:
/usr/bin/ls -1tc |tee temp
 
Old 03-30-2008, 02:20 PM   #4
djeikyb
Member
 
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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:56 PM.

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
Open Source Consulting | Domain Registration