linux script under open (shell, python, perl)
The basic characteristics of 1.bash:
ctrl+l
The key
history
And redirection pipe character 2.IO
3. Programming Fundamentals:
Principles of Programming
Program: implementation of a code of a function
Must contain: instructions, data, (logic)
Command, variable
#! / Usr / bin / python3 (python specified)
#!/bin/bash
4.grep and regular expressions! ! ! !
linux Three Musketeers: grep, sed, awk
pattern 'pattern' matches the regular expression
-------------------------------------------------------------
Logic statements
if
case-- the branch structure * for linux startup script *
for: use more, not easy to enter an infinite loop. Add to the list for the cycle
while-- specify the initial value that specifies the loop variable, the loop condition is true when entering the loop
until-- loop condition is false when entering the loop (Do not enter an infinite loop)
break
continue
return value specified program exit
read: Enter the equivalent input
echo: print output corresponding to
*variable*
--------------------------------------------------------------------
Linux Three Musketeers:
sed - stream edit d Text Editor
Memory mode:
mode:
awk-- report generator: an independent programming language
grep--
function
A fixed function code
Array
Lists, tuples, dictionaries
String
Repeat: the same data must be continuous and
De-emphasis: first ordering deduplication
Exercise:
1. Analyzing / etc / inittab file is greater than 100 lines, if yes, displays '/ etc / inittab is a big file' otherwise displays '/ etc / inittab is a small file'
#!/bin/bash
wc -l / etc / inittab | cut -d` `-f1 see the number of rows
line=`wc -l /etc/inittab | cut -d` ` -f1`
if [ $line -gt 100];then
echo "/etc/inittab is a small file"
else
echo "/etc/inittab is a big file"
be
----------------------------------------------------------------