我有一个简单的 bash 脚本,其中如果行数低于 10,则文件的内容将复制到文件 A,否则内容将复制到文件 B
这里是代码:
# File A and B are created before, since I'm in a loop
# file content is different each time. I add it either to A or B corresponding the matching.
# I know I could use wc -l directly on the file too but I don't think the problem came from
# it since i've tested both.
let nblines=$(cat file | wc -l)
if [[ $nblines < 10 ]]; then
cat file …Run Code Online (Sandbox Code Playgroud)