linux - Bash 脚本 - 将文件的最后一行复制到另一个文件

标签 linux bash

我只需将许多文件的最后一行复制到另一个文件。我怎样才能做到这一点?请帮助我。

我知道 tail 会获取最后一个文件,并且 > 将其放入其他文件,但我可以对很多文件执行相同的操作?

最佳答案

尝试:

tail -qn 1 inputfile1 inputfile2 ... > outputfile

-n 1 用于仅输出最后一行,-q 用于抑制标题。

参见:

man tail

关于linux - Bash 脚本 - 将文件的最后一行复制到另一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45936163/

相关文章:

linux - 警告 : the use of `tmpnam' is dangerous, 更好地使用 `mkstemp'

c - Linux C:类似于Shell的环境-用于单独执行-C命令? (C口译员)

c++ - inotify watcher 在 ls 或 watch 命令后停止工作

Linux Bash 自动命令,源文本文件

linux - 如何使用 sed 将文本插入到文件的第一行?

linux - 交叉编译 libSDL

c# - 使用 MPAPI 的单声道

bash - '#!/bin/sh -xe' 是什么意思?

linux - 经常在特定时间做某事

linux - 使用 bash 脚本根据给定条件使用 sed 提取位置特定记录