ATAT 专题

ATAT 文本与批处理命令

表达式、数值提取、换行转换、向上查找及按目录执行的7个命令。

更新于 2026-10-24约 5 分钟阅读按任务与环境选择适用配置
阅读本篇目录

ATAT 专题导读 · 完整教程与算例

表达式、数值提取、换行转换、向上查找及按目录执行的7个命令。 每条列出用途、输入输出、调用格式和使用条件;展开参数表可查看 ATAT 3.52 的原始英文选项与默认值。

[int] 表示整数,[real] 表示实数,[string] 表示文件名或文本;同名参数在不同命令中的含义可能不同。调用前应准备对应输入文件。

文本和批量处理#

calc#

用 awk 计算一条数值表达式。

输入与结果: 带引号的表达式 → 数值。

调用格式:

calc "2+3*4"

使用 awk 运算函数和语法;浮点结果并非任意精度。表达式参数应加引号,避免 shell 提前解释。

展开本命令的完整参数表
Syntax: calc "mathematical expression"

getvalue#

从文本中提取指定标签后的数值。

输入与结果: 标签和标准输入 → 每次匹配后的数值。

调用格式:

getvalue F < OSZICAR

标签与数值间可有等号、冒号或空白。必要时再取最后一行,避免把中间 SCF 值当最终值。

展开本命令的完整参数表
Syntax: getvalue [label]
Script that scans standard input for a given label and
write, to standard output, the numerical value following
every occurence of that label.
Any number of : = spaces or tabs can separate the label and the number.
Example: getvalue "Final energy" < gulp.output

getlines#

选取某个标记之前、之后或两个标记之间的文本。

输入与结果: 选项、一个或两个标记、标准输入 → 选定行。

调用格式:

getlines -jbt BEGIN END < text.in

-af 后面;-bf 前面;-bt 中间;j 前缀排除边界标记行。标记中的空格和正则字符需要合适引用。

展开本命令的完整参数表
Syntax: getlines [-h] [ -af | -bf | -bt | -jaf | -jbf | -bt ] string1 string2
Copies selected lines of standard input to standard output.
-h   print this help.
-af  print all lines located *after* a line containing string1
-bf  print all lines located *before* a line containing string1
-bt  print all lines located between a line containing string1 and a line containing string2
     (If there are multiple blocks of lines braketed by [begin string]
      and [end string] they are all copied.)
The prefix j means "just", indicating that the line(s) containing the matching string(s) is (are) ommited.
Don't forget to quote your strings if they contain spaces.

blanktonl#

把连续空白分隔的项目转换为逐行输出。

输入与结果: 标准输入 → 每个字段一行。

调用格式:

blanktonl < row.txt

用于处理短数值列表;会改变排版,不应直接用于需要保留列结构的完整科学文件。

nltoblank#

把换行列表连接成一行。

输入与结果: 标准输入 → 空格分隔文本。

调用格式:

nltoblank < column.txt

这是轻量文本脚本,不是通用 CSV 解析器;不要用于含特殊格式控制符的任意字符串。

fixeol#

转换文本换行符。

输入与结果: 标准输入或文件列表 → Unix/Windows 换行文本。

调用格式:

fixeol -u windows.txt

-u 转 Unix;-p 转 PC/DOS。指定文件时会创建 .bak 并写回原名,先确认文件范围;避免把二进制文件传入。

lookup#

从当前目录向上查找同名文件。

输入与结果: 文件名 → 首个找到的相对路径。

调用格式:

lookup vasp.wrap

查找深度由当前脚本限定,最多尝试六个位置;它只返回路径,不读取或修改文件。

foreachfile#

在含指定文件的子目录逐个执行命令。

输入与结果: 目标文件名和命令 → 各目录的执行输出。

调用格式:

foreachfile energy cat energy

-e 跳过 error,-n 跳过另一个文件,-a 要求另一个文件存在,-d 控制深度。带多个命令时注意分号引用;先 foreachfile 文件 pwd 检查范围。

展开本命令的完整参数表
Syntax: foreachfile [-e] [-n filename_to_skip] [-a and_filename] [-d depth] filename command
Execute the specified command in every first-level subdirectory containing the file filename.
The -e option cause foreachfile to skip directories containing the file "error".
The -n option cause foreachfile to skip directories containing the file filename_to_skip.
The -a option specifies that the file and_filename must also exist.
The -d option specifies to go down to lower level subdirectories as well (the default is 1).

原始参数表来自 ATAT 3.52,作者 Axel van de Walle 及相应贡献者。中文说明由鸢算科技编写;算法出处与论文引用。

需要根据你的体系选择资源?联系讨论计算需求。实际可用软件与权限,以当前账户和运行环境为准。

查看配图

放大后可滚动查看细节,按 Esc 关闭。

100%查看原图 ↗