LinuxQuestions.org
Register a domain and help support LQ
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, 03:47 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 248

Rep: Reputation: 1
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, 04:09 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 04:10 AM   #3
normanlinux
Member
 
Registered: Apr 2013
Distribution: Arch and SuSE
Posts: 135

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, 04:30 AM   #4
sryzdn
Member
 
Registered: Feb 2013
Posts: 248

Original Poster
Rep: Reputation: 1
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, 04:50 AM   #5
normanlinux
Member
 
Registered: Apr 2013
Distribution: Arch and SuSE
Posts: 135

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


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


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