标签: tail

仅将目录中的最后 8 个文件移动到另一个目录

我试图将最后 8 个文件从Documents目录移动到另一个目录,但我不想将它们一个一个地移动到该特定目录。是否可以用tail命令的替代品移动它们,但移动目录而不是文件?我的意思是我想用类似tail -8 ./Documents | mv ./Anotherdirectory或用mv tail -8 ./Documents ./Anotherdirectory.

事实上,我正在寻找一种聪明的方法,我可以将最后 8 个文件(如 中所列ls)快速(无需输入每个名称)移动到另一个目录。有什么建议?

command-line files directory tail mv

7
推荐指数
1
解决办法
3404
查看次数

使用 grep 突出显示在 Xterm 中不起作用

我的 Xterm 有问题。

当我使用命令时

tail -F example.log | grep -a -i -e 'examplestring'
Run Code Online (Sandbox Code Playgroud)

在 Xterm 中,“grepped”字符串不会像在普通终端中那样以红色突出显示。

我怎样才能解决这个问题?谷歌对我帮助不大。

colors tail grep kubuntu xterm

6
推荐指数
1
解决办法
632
查看次数

使用 tail -f 命令进行分页

我正在尝试使用分页尾文件:

tail -f foo.txt | more
Run Code Online (Sandbox Code Playgroud)

这工作正常,直到文件被注入,比如说,注入 200 行,当这种情况发生时,tail命令的性质是转到文件末尾,那时我失去了跟踪日志的踪迹。

有没有办法避免这种情况?

command-line tail

6
推荐指数
2
解决办法
1万
查看次数

如何仅解压缩 zip 存档的前几行?

我有一个压缩的文本文件,a.zip我想阅读它的前 10 行。是否可以在不解压缩整个文件的情况下做到这一点?

tail extract zip cat

6
推荐指数
1
解决办法
5916
查看次数

像 TAIL 这样的选项来跟踪整个文件

tail -f 插入新数据后将更新文件,但如果整个文件被重写,则会出现错误。

还有其他选项可以继续重新加载整个文件吗?

谢谢

tail

4
推荐指数
1
解决办法
774
查看次数

'tail' command not getting only the new lines

I'm using the command:

tail -f -n 0 file.txt
Run Code Online (Sandbox Code Playgroud)

But it keeps repeating itself.


  1. What I'm doing is the following:

  2. Create the file in the first terminal: touch file.txt

  3. Start the tail in the second terminal: tail -f -n 0 file.txt

  4. Edit the file in the first terminal: nano file.txt

  5. Just add text, save and close. The second terminal outputs text like it should.

  6. Edit the file again in the first terminal: nano file.txt

  7. Add in the end (2nd …

command-line bash tail

4
推荐指数
2
解决办法
6370
查看次数

头尾的区别

为什么 NUM inhead -c和的含义有区别tail -c

我将用以下命令阐明我的意思:

$ echo "words" | tail -c +1
words
$ echo "words" | tail -c +2
ords
$ echo "words" | head -c -1
words$ echo "words" | head -c -2
word$
Run Code Online (Sandbox Code Playgroud)

第一个命令什么都不做。
第二个命令删除第一个字母。
第三个命令删除换行符。
last 命令删除包括换行符在内的最后 2 个字符。

那么为什么 head 在使用时会删除 2 个字节-c而 tail 只删除一个。这看起来像一些真正的不一致或有潜在的含义吗?

command-line tail

4
推荐指数
1
解决办法
959
查看次数

tail 包含什么包?

如果我想安装或卸载它(默认情况下是否已安装),最新稳定版 Ubuntu 中包含的 tail(用于查看文件结束行的命令行工具)是什么包?

我已经安装了;我只是不记得是我安装了它还是已经在那里了。我制作了一个需要它作为依赖项的程序(这就是我问的原因)。

tail

3
推荐指数
1
解决办法
8729
查看次数

为什么重定向到 while 循环不打印消息?

这是用于跟踪文件中的更改并将内容输出到终端的 shell 代码:

while read LINE
do
  echo $LINE
done < `tail -f /var/log/messages`
Run Code Online (Sandbox Code Playgroud)

它不起作用,为什么?

command-line tail

1
推荐指数
1
解决办法
1527
查看次数

为什么 tail -f 停止跟踪 /var/log/syslog?

乌班图22.04。

我按照/var/log/syslog命令执行tail -f。这是通过 ssh 连接。它将跟踪系统日志的输出几天,然后停止更新。它就坐在那里。如果我Ctrl+C终止 tail 命令并重新发出它,它会获取最新结果,这些结果晚于tail -f. IOW,它停止跟随。如何让它继续跟踪 syslog,而不必终止命令并重新发出它?谢谢你!

command-line tail syslog

1
推荐指数
1
解决办法
271
查看次数

head 和 tail 命令输出一起在文件中

假设我有一个以file1.txt内容命名的文件1,2,3.. upto 100 linewise.

$> head -n 5 file1.txt //will display first 5 lines i.e. 1,2,3,4,5
$> tail -n 5 file1.txt // will display last 5 lines i.e. 96,97,98,99,100
Run Code Online (Sandbox Code Playgroud)

我想在 1 个命令中将内容显示为前 5 行和后 5 行,

$> head tail -n 5 file1.txt // Something like this 1,2,3,4,5   96,97,98,99,100 (both together)
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

command-line tail

0
推荐指数
1
解决办法
90
查看次数

标签 统计

tail ×11

command-line ×7

bash ×1

cat ×1

colors ×1

directory ×1

extract ×1

files ×1

grep ×1

kubuntu ×1

mv ×1

syslog ×1

xterm ×1

zip ×1