Difference between revisions of "Core utilities"

From ArchWiki
Jump to navigation Jump to search
(introduction/explanation)
 
(merge grep/ls from General Recommendations)
Line 9: Line 9:
 
* [[Useful Commands]]
 
* [[Useful Commands]]
 
* [[General Recommendations]]
 
* [[General Recommendations]]
 +
 +
==grep==
 +
[[Wikipedia:grep|grep]] is a command line text search utility originally written for Unix. The grep command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.
 +
 +
===Colored output===
 +
Beyond aesthetics, {{Codeline|grep}}'s color output is immensely useful for learning {{Codeline|regexp}} and {{Codeline|grep}}'s functionality.
 +
 +
To add it, write the following entry to {{Filename|~/.bashrc}}:
 +
export GREP_COLOR="1;33"
 +
alias grep='grep --color=auto'
 +
 +
The variable {{codeline|GREP_COLOR}} is used to specify the output color, in this example a light yellow color.
 +
 +
Although {{codeline|grep}}'s [[man page]] states that {{codeline|GREP_COLOR}} is deprecated and that {{codeline|GREP_COLORS}} is preferable, this variable does not work as of grep version 2.5.4, so use {{codeline|GREP_COLOR}} for now.
 +
 +
==ls==
 +
[[Wikipedia:ls|ls]] is a command to list files in Unix and Unix-like operating systems.
 +
 +
===Colored output===
 +
File {{Filename|~/.bashrc}} should already have the following entry copied from {{Filename|/etc/skel/.bashrc}}:
 +
alias ls='ls --color=auto'
 +
 +
The next step will further enhance the colored {{Codeline|ls}} output; for example, broken (orphan) symlinks will start showing in a red hue. Add the following to {{Filename|~/.bashrc}} and relogin, or source the file:
 +
eval `dircolors -b`
 +
 +
{{Note|These are not single quotes/apostrophes; these are backquotes/backticks/grave accents.}}

Revision as of 17:16, 10 January 2010

This article deals with so-called "core" utilities on a GNU/Linux system, such as less, ls, and grep. The scope of this article includes -- but is not limited to -- those utilities included with the GNU Template:Package Official package. What follows are various tips and tricks and other helpful information related to these utilities. If sections grow too detailed, please split into separate articles.

This page is currently under construction.

See also:

grep

grep is a command line text search utility originally written for Unix. The grep command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.

Colored output

Beyond aesthetics, Template:Codeline's color output is immensely useful for learning Template:Codeline and Template:Codeline's functionality.

To add it, write the following entry to Template:Filename:

export GREP_COLOR="1;33"
alias grep='grep --color=auto'

The variable Template:Codeline is used to specify the output color, in this example a light yellow color.

Although Template:Codeline's man page states that Template:Codeline is deprecated and that Template:Codeline is preferable, this variable does not work as of grep version 2.5.4, so use Template:Codeline for now.

ls

ls is a command to list files in Unix and Unix-like operating systems.

Colored output

File Template:Filename should already have the following entry copied from Template:Filename:

alias ls='ls --color=auto'

The next step will further enhance the colored Template:Codeline output; for example, broken (orphan) symlinks will start showing in a red hue. Add the following to Template:Filename and relogin, or source the file:

eval `dircolors -b`
Note: These are not single quotes/apostrophes; these are backquotes/backticks/grave accents.