我试图将最后 8 个文件从Documents
目录移动到另一个目录,但我不想将它们一个一个地移动到该特定目录。是否可以用tail
命令的替代品移动它们,但移动目录而不是文件?我的意思是我想用类似tail -8 ./Documents | mv ./Anotherdirectory
或用mv tail -8 ./Documents ./Anotherdirectory
.
事实上,我正在寻找一种聪明的方法,我可以将最后 8 个文件(如 中所列ls
)快速(无需输入每个名称)移动到另一个目录。有什么建议?
我的 Xterm 有问题。
当我使用命令时
tail -F example.log | grep -a -i -e 'examplestring'
Run Code Online (Sandbox Code Playgroud)
在 Xterm 中,“grepped”字符串不会像在普通终端中那样以红色突出显示。
我怎样才能解决这个问题?谷歌对我帮助不大。
我正在尝试使用分页尾文件:
tail -f foo.txt | more
Run Code Online (Sandbox Code Playgroud)
这工作正常,直到文件被注入,比如说,注入 200 行,当这种情况发生时,tail
命令的性质是转到文件末尾,那时我失去了跟踪日志的踪迹。
有没有办法避免这种情况?
我有一个压缩的文本文件,a.zip
我想阅读它的前 10 行。是否可以在不解压缩整个文件的情况下做到这一点?
tail -f
插入新数据后将更新文件,但如果整个文件被重写,则会出现错误。
还有其他选项可以继续重新加载整个文件吗?
谢谢
I'm using the command:
tail -f -n 0 file.txt
Run Code Online (Sandbox Code Playgroud)
But it keeps repeating itself.
What I'm doing is the following:
Create the file in the first terminal: touch file.txt
Start the tail in the second terminal: tail -f -n 0 file.txt
Edit the file in the first terminal: nano file.txt
Just add text
, save and close. The second terminal outputs text
like it should.
Edit the file again in the first terminal: nano file.txt
Add in the end (2nd …
为什么 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 只删除一个。这看起来像一些真正的不一致或有潜在的含义吗?
如果我想安装或卸载它(默认情况下是否已安装),最新稳定版 Ubuntu 中包含的 tail(用于查看文件结束行的命令行工具)是什么包?
我已经安装了;我只是不记得是我安装了它还是已经在那里了。我制作了一个需要它作为依赖项的程序(这就是我问的原因)。
这是用于跟踪文件中的更改并将内容输出到终端的 shell 代码:
while read LINE
do
echo $LINE
done < `tail -f /var/log/messages`
Run Code Online (Sandbox Code Playgroud)
它不起作用,为什么?
乌班图22.04。
我按照/var/log/syslog
命令执行tail -f
。这是通过 ssh 连接。它将跟踪系统日志的输出几天,然后停止更新。它就坐在那里。如果我Ctrl+C终止 tail 命令并重新发出它,它会获取最新结果,这些结果晚于tail -f
. IOW,它停止跟随。如何让它继续跟踪 syslog,而不必终止命令并重新发出它?谢谢你!
假设我有一个以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)
我怎样才能做到这一点?