我有一个带有 IPv4 地址的输入文件:
94.228.16.0 - 94.228.25.255
94.241.136.0/24
94.241.136.0 - 94.241.136.255
94.29.128.0/17
94.29.128.0 - 94.29.191.0
94.29.192.0 - 94.29.255.0
94.74.181.0/24
94.74.181.0 - 94.74.181.31
94.74.181.128 - 94.74.181.255
Run Code Online (Sandbox Code Playgroud)
如何将地址范围转换为网络掩码?结果应该是:
94.228.16.0/21
94.241.136.0/24
94.241.136.0/24
94.29.128.0/17
94.29.128.0/19
94.29.192.0/19
94.74.181.0/24
94.74.181.0/27
94.74.181.128/25
Run Code Online (Sandbox Code Playgroud) 我有一个文本文件:
cat test1
ch140/121_------_T_201607061430
ch140/121_------_T_201611070840
ch140/121_------_T_201611071125
ch140/121_------_T_201611071235
Run Code Online (Sandbox Code Playgroud)
我想将文本逐行添加到此文件中:
/121_------_T_201607061430
/121_------_T_201611070840
/121_------_T_201611071125
/121_------_T_201611071235
Run Code Online (Sandbox Code Playgroud)
结果必须是:
ch140/121_------_T_201607061430/121_------_T_201607061430
ch140/121_------_T_201611070840/121_------_T_201611070840
ch140/121_------_T_201611071125/121_------_T_201611071125
ch140/121_------_T_201611071235/121_------_T_201611071235
Run Code Online (Sandbox Code Playgroud)
我用了:
cat test1 | sed -e 's/ch140//' > test2
for a in $(cat test2)
do
????
done
Run Code Online (Sandbox Code Playgroud)
我可以为此使用什么命令?
我尝试使用sed命令,但没有用。
我有带有文本的文件:
1861_ASSET-D_T_201702181000-201702181045_HN_
197895_STRING-H_T_201702181000-201702181045_HN_
14512861_FILE-FD_T_201702181000-201702181045_HN
Run Code Online (Sandbox Code Playgroud)
如何使用 egrep、awk 或 sed 在第一个和第二个匹配项“_”之间分配文本?
我希望有:
ASSET-D
STRING-H
FILE-FD
Run Code Online (Sandbox Code Playgroud) 我尝试在 Ubuntu 14.04.3 (x86_64) 中通过 pip3 安装“PyGreSQL”(pgdb)模块
pip3 install PyGreSQL
Run Code Online (Sandbox Code Playgroud)
但我有一个错误:
Downloading/unpacking PyGreSQL
Downloading PyGreSQL-5.0.4.tar.gz (637kB): 637kB downloaded
Running setup.py (path:/tmp/pip_build_root/PyGreSQL/setup.py) egg_info for package PyGreSQL
/bin/sh: 1: pg_config: not found
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/PyGreSQL/setup.py", line 88, in <module>
pg_version = pg_version()
File "/tmp/pip_build_root/PyGreSQL/setup.py", line 82, in pg_version
match = re.search(r'(\d+)\.(\d+)', pg_config('version'))
File "/tmp/pip_build_root/PyGreSQL/setup.py", line 74, in pg_config
raise Exception("pg_config tool is not available.")
Exception: pg_config tool is not available.
Complete output …Run Code Online (Sandbox Code Playgroud)