“〜"代表什么?字符表示文件名的结尾(Linux) [英] What does the "~" character signify at the end of a filename (linux)

查看:87
本文介绍了“〜"代表什么?字符表示文件名的结尾(Linux)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/tmp/stream 中重复执行 ls -l <​​/code>命令,并且收到以下输出:

I am repeatedly executing the ls -l command within /tmp/stream and I receive the following output:

pi@dewsaq18 /tmp/stream $ ls -l
total 112
-rw-r--r-- 1 pi pi 112812 Feb  7 03:32 pic.jpg
pi@dewsaq18 /tmp/stream $ ls -l
total 112
-rw-r--r-- 1 pi pi 112812 Feb  7 03:32 pic.jpg
-rw-r--r-- 1 pi pi      0 Feb  7 03:32 pic.jpg~
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 116748 Feb  7 03:32 pic.jpg
-rw-r--r-- 1 pi pi      0 Feb  7 03:32 pic.jpg~
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 117608 Feb  7 03:32 pic.jpg
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 117608 Feb  7 03:32 pic.jpg
-rw-r--r-- 1 pi pi      0 Feb  7 03:32 pic.jpg~
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 118674 Feb  7 03:32 pic.jpg
-rw-r--r-- 1 pi pi      0 Feb  7 03:32 pic.jpg~
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 118147 Feb  7 03:32 pic.jpg
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 118147 Feb  7 03:32 pic.jpg
-rw-r--r-- 1 pi pi      0 Feb  7 03:32 pic.jpg~
pi@dewsaq18 /tmp/stream $ ls -l
total 116
-rw-r--r-- 1 pi pi 117175 Feb  7 03:32 pic.jpg
pi@dewsaq18 /tmp/stream $

......and so on

我的问题是-在第二个(空)文件中附加〜"字符到底是怎么回事?为什么每次执行 ls -l <​​/code>时都不会显示此文件?

My question is - what exactly is going on with the "~" character appended to the second (empty) file? Why doesn't this file show up each time ls -l is executed?

由于我使用的是静态文件名 pic.jpg ,并且每次拍摄新图像时都会覆盖该图像,所以我最初的想法是 pic.jpg〜文件的用途是比较各帧之间的变化.

Since I'm using a static filename pic.jpg and the image is overwritten each time a new one is taken, my initial thought was the pic.jpg~ file's use was to compare changes between frames.

但是,它并不总是存在的(也许没有变化,所以不需要吗?),甚至更是如此,它始终是空的,根本没有写入任何数据.

However, it isn't always there (maybe there were no changes, so it is not needed?) and, even more so, it is always empty without any data written to it at all.

感谢您的帮助和指导.

推荐答案

文件名末尾的波浪号()通常用于表示备份文件.因此,如果您有文件 foo.bar 并对其进行编辑并保存,则新保存的文件将为 foo.bar ,而先前的版本将为 foo.bar〜.但这取决于程序:并非所有的编辑器或程序都将文件的先前版本保存为备份,并且如果这样做,它们都不会遵循附加波浪号()的约定.从字面上看这不是一个标准,而是一个非常常用的约定.

The tilde (~) at the end of a file name is often used to signify a backup file. So if you have a file foo.bar and you edit it and save it, the new saved file would be foo.bar and the previous version would be foo.bar~. But it's program dependent: not all editors or programs would save the prior version of a file as a backup, and if they do, they don't all follow the convention of appending a tilde (~). It's not literally a standard, but rather a very commonly used convention.

这篇关于“〜"代表什么?字符表示文件名的结尾(Linux)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆