当前位置:网站首页>22/02/15 study notes
22/02/15 study notes
2022-06-28 07:44:00 【Zeiyalo】
One 、 Some instruction sets
Count the number of lines in a file :
Instructions :
wc -l file name

Count the number of files in a folder :
Instructions :
ls -l|grep "^-"|wc -l

Count the number of directories :
- Only check the number of directories under the current directory
Instructions :
ls -l|grep "^d"|wc -l

- When viewing the number of directories under the current directory, include the child directories
Instructions :
ls -lR|grep "^d"|wc -l

Homework :
1. Query the number of all destination files with the specified prefix name in the current path
Two 、liunx user 、 Group 、 jurisdiction
1.ls And ll
Use ll When viewing directories and files in the current directory , The meaning of the first column above :
The first letter represents the file type ;
The last nine characters correspond to the corresponding owner 、 Generic group 、 other
Character meaning
Empowerment :chmod、chgrp、chown
Authority modification
Switching users :su
3、 ... and 、shell Programming
1. first shell Program
Use vi The editor enters the writer in it firstshell, And then use ./firstshell Calling procedure ;
among ,#/bin/bash It's an interpreter ,echo Is the output keyword ;
adopt ./firstshell You can call the program directly , Output helloworld;
2. Variable
(1) data type
shell There are only two data types in , String and integer ;
stay shell You can add... Before the variable readonly Keyword to create a variable equivalent to a constant ( After adding the read-only keyword, the save can only be read , Cannot be modified )

(2) Delete variables
To delete a variable, we can use unset To delete variables ;
for example :
give the result as follows :
It is not a report but an error, but there is no output on it , It is reasonable to guess that the variable also exists, but its memory is modified to be empty ;
ok , Query the information to know , Obviously wrong , No error is reported because when using variables as output , It was originally unset The released variable has a variable with the same name created , That's it ;
Pass the test , You can see that directly calling variables as output can also directly output , The result is the same as above ;
(3) Keyboard entry
You can enter variables through the keyboard , Use read Variable To read a row of data , Enter to end ;
3. Arithmetic operator
Format example :
#/bin/bash
sum=`expr 1 + 1`
sub=`expr 5 - 2`
chu=`expr 4 / 2`
mul=`expr 3 \* 3`
ehco ${sum}
Output example :
- Be careful : When doing the four operations, we should pay attention to the multiplication
*You need to use an escape character to escape , That is to use\*, In addition, the remainder operation can also be performed in shell Use in (%).
4.shell Programming structure
(1) Branching structure
form :
#!/bin/bash
if ((5>7))
then
echo " Five and seven "
else
echo " Five less than seven "
fi
(2) Loop structure
Format example :
#!/bin/bash
sum=0
for((i=1;i<=100;i++))
do
((sum+=i))
#let sum+=i
#sum=`expr $sum + $i`
#sum=$((sum+i))
#sum=$(($sum+$i))
#((sum=$i+$sum))
done
echo $sum
Homework : Output 20 The Fibonacci series ;
#!/bin/bash
p=0
j=1
sum=0
for((i=1;i<=20;i++))
do
echo ${j}
((sum=p+j))
#sum=`expr $p + $j`
p=$j
j=$sum
done
边栏推荐
- 异或的应用。(提取出数字中最右侧的1,面试中经常用的到)
- DBeaver 22.1.1 发布,可视化数据库管理平台
- Safety training is the greatest benefit for employees! 2022 induction safety training for new employees
- MMR rearrangement (similarity is calculated by editing distance and repeatability)
- A gadget can write crawlers faster
- Co process, asyncio, asynchronous programming
- What is the lifecycle of automated testing?
- Redis implements distributed locks
- Source code analysis of kubernetes' process of deleting pod
- Rediscluster cluster mode capacity expansion node
猜你喜欢

Recommended system series (Lecture 5): Optimization Practice of sorting model

What is EC blower fan?

Kubernetes理论基础

Sword finger offer|: linked list (simple)

Section Xi. Axi of zynq_ Use of DMA

推荐系统系列精讲(第五讲): 排序模型的调优实践

云原生(待更新)

网传互联网公司加班表,排名第一的没悬念

asp. Net datalist when there are multiple data displays

asp. Net registration page
随机推荐
Source code analysis of kubernetes' process of deleting pod
Cloud native (to be updated)
GPIO configuration of SOC
Ice, protobuf, thrift -- Notes
Unity-UI-shadow组件
open62541直接导入NodeSet文件
Helloword routine for ROS
云原生:云计算技术再次升级 开启全面云开发时代
es数据导出csv文件
Localization SoC development plan
HJ进制转换
剑指Offer||:链表(简单)
NDK cross compilation
In idea, the get and set methods may be popular because the Lombok plug-in is not installed
Section 9: dual core startup of zynq
HJ string sort
HJ character count
Understanding of OPC protocol
Porting ucosiii to stm32f429
Analyze 5 indicators of NFT project