03_02bash Features Explained

Source: Internet
Author: User
Tags aliases

Linux file wrapping is expressed in $, Windows is represented by $+enter, so the Linux text is used
Windows Notepad is open with only one line;
CAT-E can see that the end of a line has $
Cat-n Show number of lines



Tail-f can view the appended content in real time, this is very important, can be used to see the web update log;;
# #文本处理命令


Cut command
Cut
-D: Specifies the field delimiter, which is the default space
-F: Specify the fields to display
Cut-d:-F 1,3/ETC/PASSWD
Cut-d:-F 1-3/etc/passwd
Awk-f: ' {print '} '/etc/passwd-f-D option similar to cut
Wc-l/etc/passwd | Cut-d '-f1

##
Sort command

The sort command is arranged in ascending order of the initial letter size
Sort Sort.txt
-N: Ascending in order of size
-R: Descending order of initial letter size
-U: Remove redundant duplicates
-F: Ignore character case when arranging
Sort-n-R: Descending in order of size

sort/etc/passwd

SORT-T:-k3-n/etc/passwd
-T: Indicates that the field is sorted by delimiter
-K sorts which field to use for the keyword
(usually this can be combined with uniq)



##
Uniq command
Uniq
-D: Indicates adjacent duplicate rows
-D: Indicates rows that are adjacent to duplicate and lists the number of repetitions
-C: Indicates the number of repetitions of a row adjacent



##
WC command

Wc:
WC Test1.txt
4 4 Test1.txt
Number of lines of words bytes

-L: Show only the number of rows


##
TR command
Convert or delete characters

such as:

#tr a A
Abababab (carriage return)
Abababab
#tr AB AB
Acbdd
Acbbd
(that is, replace all characters to be uppercase and lowercase)
To case the ad characters in/etc/passwd:
TR AD AD </etc/passwd
If all uppercase and lowercase are converted:
TR A-Z

-D Delete
tr-d ABCD < Test2.txt
Will delete all the A/B/C/D




##
Type command
Determine whether a name is currently alias, keyword, function, builtin, file, or nothing:

The output of type LS is the alias of LS--color=auto ' ls '
The output of type if is the IF is the Shell keyword
The output of type type is the type of shell inline
The output of type gedit is Gedit is/usr/bin/gedit
The output of type frydsh is bash:type:frydsh: not found
Http://www.2cto.com/os/201211/168885.html

Bash and its features:
Shell: Shell

Process: In each process it appears that the current host has only the kernel and the current process
A process is a copy of a program, and a process is a program execution instance


Shell, child shell

Example:
#csh
This is the time to switch to CSH, ctrl+d back to the original shell.

Bash:
1/Command history
2/Pipe/redirect
3/Command Aliases
4/Command line editing
5/Command Line expansion
6/File name wildcard
7/variable
8/programming

command-line editing:
Cursor Jump:
CTRL + A: Skip to the beginning of the command
Ctrl+e: Jump to the end of the command line
Ctrl+u: Delete the cursor to the beginning of the command line
CTRL+K: Delete the cursor to the end of the command line

Command history: ~/.bash_history holds the command for the historical execution
History-c: Emptying command history
history-d 500 Delete No. 500 command
history-d 500 10 Delete No. 500 after 10 commands
!n: Execute nth command
!-n: Execute the countdown to the nth command
!: Executes the previous command
!+string:
If the command history executes the Ls/cd/ps-aux command, it can be executed directly!l to execute LS, but this technique, which can be represented by a string that distinguishes it from all executed commands;
! $: Parameter referencing the previous command
Environment variables:
Path: Command Search Path
Histsize: Specifies the command history size (Red Hat series default) echo $HISTSIZE
Shell: Indicate shell

Command aliases:
Alias CLS ' Clear '
Valid only in the life cycle of the current shell
Revoke aliases
Unalias + aliases
Unalias CLS


#命令替换: $ (Command) ' anti-quote '
Put the results of the implementation
echo "The current directory is $ (PWD)."

For example, create a file and include the current date:
Touch a_$ (date +%f). txt
Touch a_$ (date +%f-%h-%m-%s). txt

Touch b_ ' Date +%f '. txt

Quotes supported by bash:

": Command substitution
"": weak effect, can implement variable substitution
': Strong reference, do not complete variable substitution


File name wildcard:

*: Any character of any length
?: any single character
[]: matches any single character within the specified range:
[Abc],[a-m],[a-z],[a-z],[0-9],[a-za-z]
LS [a-za-z]*[0-9]
[^]: matches all characters outside the specified range:
LS [^0-9]*

Practice:
Touch a.txt A.txt b.txt 1.txt
#ls [a-z]*
A.txt A.txt B.txt
#ls [^a-z]*
1.txt
. So share object

This article is from the "linuxer" blog, make sure to keep this source http://x180x.blog.51cto.com/10473748/1669555

03_02bash Features Explained

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.