用bash遍历C,CaO, NaCl, MgO ,NO,MoO,FeO这几个化学结构,结构式中包含K,Ca,Sr,Ti,V,Cr,Mn,Fe,Co,Ni,Cu,ZnGa,Ge,As,Br,Sr,Y,Zr,Mo,Ba,Ce,Np,Pm,Sm,这些元素中的一种就不打印出来
时间: 2023-05-18 11:04:55 浏览: 47
可以使用以下的bash代码来遍历这些化学结构:
```
for structure in C CaO NaCl MgO NO MoO FeO; do
if [[ $structure != *"K"* && $structure != *"Ca"* && $structure != *"Sr"* && $structure != *"Ti"* && $structure != *"V"* && $structure != *"Cr"* && $structure != *"Mn"* && $structure != *"Fe"* && $structure != *"Co"* && $structure != *"Ni"* && $structure != *"Cu"* && $structure != *"Zn"* && $structure != *"Ga"* && $structure != *"Ge"* && $structure != *"As"* && $structure != *"Br"* && $structure != *"Sr"* && $structure != *"Y"* && $structure != *"Zr"* && $structure != *"Mo"* && $structure != *"Ba"* && $structure != *"Ce"* && $structure != *"Np"* && $structure != *"Pm"* && $structure != *"Sm"* ]]; then
echo $structure
fi
done
```
这个代码会遍历每一个化学结构,如果结构式中包含上述元素中的任意一个,就不会打印出来。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)