starting with the N1 character from the right.Example:Variable= ' http://www. your domain name. com/cut-string.html 'Echo ${variable:0:4}Result: httpEcho ${variable:7}Result: www. your domain name. com/cut-string.htmlEcho ${variable:0-15:10}Results: cut-stringEcho ${variable:0-15}Results: cut-string.htmlThe third type:With other shell commands, such as cutThere are several main options for the Cut command:echo $variable | Cut-c1-4Result: httpecho $variable | cut-c8-Result: www. your domain name
"
\{n,\}
matches the previous line with the last character repeat number at least n times
\{n\}
matches the line with the previous character repeated n times
example 1:[[email protected] tmp]# grep"^th"Regular_express.txt ThisDress doesn't fit me.example 2:[[email protected] tmp]# grep"y$"Regular_express.txt"Open Source" isa good mechanism to devolop programsyapple isMy favorite Foody example 3:[[email protected] tmp]# grep"425.0"Regul
Very powerful text manipulation tool, Sed,awk,grep This three command is the operation of the text fileThe UNIX system has several very special features:1. For the kernel, UNIX files are byte sequences. IO devices are also files.2. The meaning of the document is referred to the application for interpretation. The text files are very important because UNIX provides a lot of utilities (utility), which are rel
Tags: linu lis $ padding pre row to column strong invalid forRow to columnThe sample file is as followsCat File.txta B CD e FG H i
cat file.txt |xargs -n1
xargs -n 1
tr " " "\n"
4.sed 's/ /\n/g' file.txtThis command works on Linux and does not work on Mac because sed on Mac is BSD version, GNU version on Linux, need to use on Macsed -e 's/ /\'$'\n/g' file.txt5.
.$: Contains the text content of the first field.awk ' {print $} ' filename prints the fifth column.Print permissions and file names for files in the current directory:awk ' {print $ ': ' $9} 'Total-rw-rw-r--.: BsdmakefileDrwxrwxr-x.:config-rw-rw-r--.: config.inDrwxrwxr-x.:d OCSDrwxrwxr-x.:feeds-rw-rw-r--.: Feeds.conf.defaultTo remove a sentence that contains a word in a file:Sed ' s/[^.] *mobile phone[^.] *\ . G ' filenameRemove the sentence that contains the word "mobile phone".The format of t
Text processing cat more less head tail sort uniq grep cut jion sed awk################################################cat:concatenate files and print on the standard output display the contents of the file to the normal outputs (display)-E: Displays the last character at the end-N: Show line numbering[Email protected] ~]# cat-n/etc/shells1/bin/sh2/bin/bash3/sbin/nologin4/bin/dash5/bin/tcsh6/bin/csh[Email p
AwkAwk is a programming language that has a strong ability to handle document data. AWK specializes in formatting messages from or from a large textExtract data from this document.AWK's command format is:awk [-F Filed-separator] "commands" input-file (s)awk divides a line of text by the delimiter (filed-separator) into multiple fields, which are then recorded as $1,$ 2 ... $ n. $Represents all domain values
files that include W and tGrep-e "W*t" fileFind rows greater than 560 less than 893 in file filesGrep-e "[5-8][6-9][0-3]"Find a row with two 9 in a fileGrep-e "9{2}" fileFind rows that are larger than two 9Grep-e "9{2,}" fileFinding blank lines in a fileGrep-e "^$" fileFind included? The linegrep "?" FileFind lines in a file that start with WGrep-e "^w" fileFind rows in a file that are not preceded by WGrep-e "^[^w]" fileawk Data Flow processing toolFind each column in the log fileawk ' {print
Took an e-mail address, want to go to the address of the heavy.Open the file a look, several columns. There are comma distinctions and there are spaces to distinguish
9589,860122@qq.com,1,1,2015-04-08 15:31:07.763000000, Xianyang, Shaanxi Province, qq.com,59590,4605708@qq.com,1,1,2015-04-08 15:31:07.763000000, Shenzhen, Guangdong Province, qq.com,59591,3307150@qq.com,1,1,2015-04-08 15:31:07.763000000, Hangzhou city, Zhejiang Province, qq.com,59592,1378747@qq.com,1,1,2015-04-08 15:31:07.76300000
Regular expressions: Regular expressions are a set of rules and methods that are defined for processing a large number of strings.Regular expressions are widely used in almost all languages (e.g. Java, C, C + +, PHP, Python, etc.)==================== Basic Regular =====================^ Match with what to start with, ^w matches content starting with W$ match with what ends, $w matches content ending with W^$ Matching Blank lines. Represents and can only represent any one character\ escape charac
Knowledge Point Grooming: Click the link to enter1. Shell Introduction and variables, scripting related concepts2. Bash Programming: Condition testing3. Bash Programming: arithmetic operations4. Bash Programming: If statements5. Bash Programming: Case statements, read and user interaction6. Bash Programming: Process Control7. Bash Programming: functions and Arrays8. sed command--stream editor9. awk Command-
1. grep1, 1 grep [-INVC] [--color=auto] ' search string ' filenameOptions and Parameters:-I: Ignore different case-n : Output line number by the way-v : Displays rows without a ' search string '--color=auto: Add color to the found part-C: Count the number of rows found-A2: Matching line and 2 rows below it-B2: Matching line and 2 rows above it-C2: Matching line and 2 rows above itgrep and regular expressionsGrep-n ' ^$ ' file #空白行Special charactersLinux-grep
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.