LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-03-2014, 02:47 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Rep: Reputation: 9
a question on shell internal command


Hi,

Why do I receive this when I want to know the type of "ls". Isn't it an internal shell command?

Quote:
$ type ls
ls is aliased to `ls --color=auto'
 
Old 02-03-2014, 03:09 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
ls is not a shell built-in but a program provided by coreutils. The message you receive states that you have an alias that causes ls to display a colored output and the alias is usually defined in a script under /etc/profile.d. To see what ls really is, try
Code:
type -a ls
 
1 members found this post helpful.
Old 02-03-2014, 03:10 AM   #3
normanlinux
Member
 
Registered: Apr 2013
Location: S.E. England
Distribution: Arch
Posts: 161

Rep: Reputation: Disabled
ls is found, normally, at /usr/bin/ls, and is part of the coreutils package
It defaults to *not* displaying in colour but has options to control this, the most useful being that used in your alias.

This is common on Linux systems as, while we like (and are used to) the colour coding on our terminals the escape sequences used would screw up the following processes if used in a pipe or redirected to a file.
 
Old 02-03-2014, 03:30 AM   #4
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Original Poster
Rep: Reputation: 9
Quote:
Originally Posted by normanlinux View Post
This is common on Linux systems as, while we like (and are used to) the colour coding on our terminals the escape sequences used would screw up the following processes if used in a pipe or redirected to a file.
Thank you, but I don't understand why colour coding on terminals may screw up the processes?!
When we execute "ls", depending on what we have on the list their colours are different. But what does it have to do with escapes?
 
Old 02-03-2014, 03:50 AM   #5
normanlinux
Member
 
Registered: Apr 2013
Location: S.E. England
Distribution: Arch
Posts: 161

Rep: Reputation: Disabled
In order to display the colours, the ls program surrounds the file names with terminal sequences that set and then reset the display colour. These normally start with the escape character 0x1b, so they are called escape sequences. If these were passed to a following process - or included in a file for later processing - the process would not be able clearly t see the file names.
 
1 members found this post helpful.
  


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
[SOLVED] Quick, simple, shell command question JoshConsulting Linux - Newbie 8 06-03-2010 06:13 PM
Shell Script format question - output command results in quotes Barefootpanda Linux - General 5 10-13-2008 11:40 PM
question about the ls command in shell stocky021 Programming 10 11-01-2007 09:43 AM
shell command script question.... Basslord1124 Linux - Software 2 04-11-2007 04:36 PM
A shell command simple question the_rhino Linux - Newbie 6 09-13-2004 01:57 PM

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

All times are GMT -5. The time now is 06:40 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
Open Source Consulting | Domain Registration