tcl文本第一列是” file /proj/PD/yy/router1 cell_name: ",第二列是 ” file /proj/PD/yy/ric1 cell_name: ",我要用sed命令将文本中router1 和 ric1两个字符串复制到行尾
时间: 2024-09-29 12:14:35 浏览: 46
你可以使用`sed`命令结合正则表达式来完成这个任务。假设原始文件名为`input.txt`,并且内容如你描述的那样,可以尝试以下命令:
```bash
sed -i '/^file \// {s/(cell_name: ")\(.*\)/\1\2 router1"/; s/(cell_name: ")\(.*\)/\1\2 ric1"/} input.txt
```
这里解释一下命令:
- `sed -i`:在原文件上直接修改(如果存在备份,通常会在文件名后添加~作为备份)。
- `/^file \/`:匹配每一行开始以`file /`开头的部分。
- `{...}`:定义了一个处理模式块。
- `s/(cell_name: ")\(.*\)/\1\2 router1"/`:在找到`cell_name:`及其后的内容后,追加` router1`。
- `s/(cell_name: ")\(.*\)/\1\2 ric1"/`:同样地,在找到`cell_name:`及其后的内容后,再追加` ric1`。
运行上述命令后,`input.txt`中的`router1`和`ric1`会分别添加到对应行的`cell_name:`之后。
相关问题
File "1.py", line 64, in <module> in_proj = pyproj.Proj(int='epsg:4326') File "/home/admin1/anaconda3/envs/CFANet/lib/python3.6/site-packages/pyproj/__init__.py", line 358, in __new__ return _proj.Proj.__new__(self, projstring) File "_proj.pyx", line 84, in _proj.Proj.__cinit__ RuntimeError: b'projection not named'
这个错误是由于在创建 pyproj.Proj 对象时传入的投影字符串(projstring)不正确导致的。根据你提供的代码,问题出现在第 64 行,其中你正在尝试使用 'epsg:4326' 这个投影字符串创建一个 pyproj.Proj 对象。
可能的原因是 'epsg:4326' 不是一个有效的投影名称。请确认你使用的投影名称是否正确。另外,你可以尝试使用其他有效的投影字符串来创建 pyproj.Proj 对象。
如果问题仍然存在,请提供更多代码和上下文信息,以便我更好地帮助你解决这个问题。
PROJ: proj_create_from_name: D:\anaconda3\Library\share\proj\\\proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR
根据提供的引用内容,错误信息提示了proj.db缺少DATABASE.LAYOUT.VERSION.MAJOR的元数据,这可能是由于来自另一个PROJ安装的proj.db文件引起的。为了解决这个问题,可以尝试以下方法:
1. 确保proj.db文件来自正确的PROJ安装。如果你有多个PROJ安装,请确保使用正确的proj.db文件。
2. 检查proj.db文件的元数据。可以使用SQLite数据库工具或Python的sqlite3模块来查看proj.db文件的元数据。确保DATABASE.LAYOUT.VERSION.MAJOR和DATABASE.LAYOUT.VERSION.MINOR的元数据存在。
3. 如果proj.db文件确实缺少元数据,可以尝试重新安装PROJ或更新PROJ版本。确保使用官方提供的最新版本。
4. 如果以上方法都无效,可以尝试手动添加缺少的元数据。使用SQLite数据库工具或Python的sqlite3模块打开proj.db文件,并添加DATABASE.LAYOUT.VERSION.MAJOR和DATABASE.LAYOUT.VERSION.MINOR的元数据。
请注意,修改数据库文件可能会导致其他问题,因此在进行任何更改之前,请备份proj.db文件。
阅读全文
相关推荐
















