ls | grep -v '~$'
is the quick solution. It uses ls to list all (non-hidden) files, then uses grep with -v
(inverted matching, i.e., exclusion) to exclude all lines with the tilde (~
) at the end ($
).
HOWEVER, if you have ANY files named like something1, something2, it's a HUGE smelly indicator that you have a bad workflow, which you should fix at the source, not with clunky hacks like modifying how ls works.
If you find yourself naming files with version numbers, like test1 and test2 or testone and testtwo, then what you really want is a version control system, like git
.
This is especially true in your case, where you have multiple versions of multiple files, and the versioning seems to need to be coordinated between all of the files.
Version control systems let you essentially overlay a time window onto the filesystem, so you only see the one test
file, but under the hood (through the version control program) all versions are available to search through, retrieve, revert to, compare with, etc.
Once you have this set up, you no longer need backup files from your editor, because version control has the history of the files since you started using it, even if you've made a thousand changes since then. You can even "branch" the history timeline, trying out a new idea, and going back in time and then forward to try a different idea, if you need to.
~
. These file are backup files created my some text editors.ls -l
(letter ell) would include the permissions, nlinks, owner, size and modtime for each file listed. What would produce the output you show isls -1
(digit one) and on many systems-1
is needed to produce single-column output on the terminal, but whenls
is piped (as here togrep
) or redirected,-1
is not needed, it is already single-column.