0

From terminal, how to list files with 2 dots or more then later manually judiciously rename files.

Six (6) file examples:

a..txt
b.txt.
codec-pack-2.6.1.0_en.txt
d...txt
e....
..f.txt

Using: Ubuntu 20.04.4 LTS (Focal Fossa)

Some success with

find . -type f -name '*.*.*' |sort

The above command outputs 4 of 6 files:

./a..txt
./codec-pack-2.6.1.0_en.txt
./d...txt
./..f.txt

and misses 2 files:

b.txt.
e....

The command below did not find above 2 files that end with a dot .:

find . -type f -name '*\.'

How to List files with 2 Periods (dots), or more?

--

More information requested.

$ find . | od -c
0000000   .  \n   .   /   a   .   .   t   x   t  \n   .   /   b   .   t
0000020   x   t  \n   .   /   c   o   d   e   c   -   p   a   c   k   -
0000040   2   .   6   .   1   .   0   _   e   n   .   t   x   t  \n   .
0000060   /   d   .   .   .   t   x   t  \n   .   /   e  \n   .   /   .
0000100   .   f   .   t   x   t  \n   .   /   1   1   _   e   m   p   t
0000120   y   .   t   x   t  \n
0000126

--

More information requested.

  • What is the filesystem?
  • What is the GUI program exactly?
$ lsblk -f
FSTYPE = vfat for a usb flash drive, stick.
gnome-shell --version
GNOME Shell 3.36.9
___________ 3.36.8 by visible GUI in Settings .1 difference
$ apt-cache show gnome-shell | grep Version
Version: 3.36.9-0ubuntu0.20.04.2
Version: 3.36.4-1ubuntu1~20.04.2
Version: 3.36.1-5ubuntu1
$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
phuclv
  • 26,555
  • 15
  • 113
  • 235
joseph22
  • 157
  • 1
  • 9
  • 2
    You're pretty close, you just need to backslash your periods in the first query. There's a big difference between `.` and `\.` – Barry Carter Aug 01 '22 at 17:04
  • In my tests in Kubuntu 22.04 LTS, with `find` from GNU findutils 4.8.0, the command `find . -type f -name '*.*.*' |sort` found all the 6 files. Is Windows world in any way connected to your case? (WSL, NTFS, …). – Kamil Maciorowski Aug 01 '22 at 17:14
  • Hello Barry, 4 of 6 files found with: ```find . -type f -name '*\.*\.*' |sort``` shows ```./a..txt ``` ./codec-pack-2.6.1.0_en.txt ```./d...txt ``` ./..f.txt – joseph22 Aug 01 '22 at 17:43
  • Helo Kamil. Is Windows world in any way connected to your case? Yes. Bouncing between ms Windoze and Ubuntu 20.04 with FAT32, NTFS, ext4. Ubuntu 20.04.4 LTS (Focal Fossa) ```find --version``` is ```find (GNU findutils) 4.7.0``` – joseph22 Aug 01 '22 at 17:44
  • Does `find . -name '*.*.*'` also miss 2 files? – Kamil Maciorowski Aug 01 '22 at 17:57
  • ```find .``` shows 7 files : ```.``` ./a..txt ```./b.txt``` ./codec-pack-2.6.1.0_en.txt ```./d...txt``` ./e ```./..f.txt``` note the file ```e....``` is truncated to ```./e``` – joseph22 Aug 01 '22 at 18:05
  • ```find . -name '*.*.*' ``` shows 4 of 6 files, 2 files missing. ```./a..txt``` ./codec-pack-2.6.1.0_en.txt ```./d...txt ``` ./..f.txt – joseph22 Aug 01 '22 at 18:06
  • OK then. What is the output of `find . | od -c`? Please do not post this in a comment. [Edit] the question and post there. – Kamil Maciorowski Aug 01 '22 at 18:09
  • 1
    Your `find` obviously "thinks" there are files `b.txt` and `e`. Why do *you* think there are `b.txt.` and `e....`? What exact command told you these names? Or with what exact command did you create files with these alleged names? – Kamil Maciorowski Aug 01 '22 at 18:18
  • ```touch G...``` is visible in GUI as 4 characters, said differently files that end with a dot. GUI = Graphical User Interface. but ```find .``` sees file as 1 character ```./G``` not 4 characters. – joseph22 Aug 01 '22 at 18:43
  • What is the filesystem? What is the GUI program exactly? – Kamil Maciorowski Aug 01 '22 at 18:46
  • See addition to Question. – joseph22 Aug 01 '22 at 19:19
  • 1
    When I asked about connection to the Windows world, I meant this specific case, the problem. The reason I asked is here: [filenames in Win32 namespace are not allowed to contain dots at the end](https://superuser.com/a/1533170/432690). Now I strongly suspect vfat is the culprit. AFAIK the command you used (that worked for me) is by all Linux standards the right command to do what you want to do; it would work on ext4 or btrfs because the files would keep these names in the first place. – Kamil Maciorowski Aug 01 '22 at 19:22
  • Copied files from vfat usb to Music. ```pwd``` dir ```/home/u3/Music/xx```and this dir should be ext4. And ```find . -type f -name '*.*.*'``` shows 4 of 6 files. – joseph22 Aug 01 '22 at 19:32
  • "this dir should be ext4. And `find . -type f -name '*.*.*'` shows 4 of 6 files" – So maybe the other 2 were copied without trailing dots in their names. Have you checked this thoroughly in the new location? – Kamil Maciorowski Aug 02 '22 at 04:30
  • Kamil you are correct. ```find . -type f -name '*.*.*'``` shows 4 of 6 files. The other 2 files have less than 2 dots & that means ```b.txt``` & ```e``` _ On another note I did Live USB Kubuntu 22.04.1 and ```find . -type f -name '*.*.*'``` works, suspect bug in Ubuntu 20.04.4 regarding List files with 2 Periods (dots), or more – joseph22 Aug 03 '22 at 02:09

1 Answers1

0

You can try something like:

ls -a *\.*\.*

the -a is to show files starting with . Here is example:

# find .
.
./..f.txt
./a..txt
./b.txt.
./codec-pack-2.6.1.0_en.txt
./d...txt
./e....
# ls -a *\.*\.*
..f.txt                    b.txt.                     d...txt
a..txt                     codec-pack-2.6.1.0_en.txt  e....

Here is example of vertical listing:

# ls -1a *\.*\.*
..f.txt
a..txt
b.txt.
codec-pack-2.6.1.0_en.txt
d...txt
e....
Romeo Ninov
  • 5,319
  • 5
  • 20
  • 20
  • Helo Romeo, 3 of 6 files found with: ```ls -a *\.*\.*``` gives ```a..txt ``` codec-pack-2.6.1.0_en.txt ```d...txt``` for a vertical list use ```ll``` means ```ll -a *\.*\.*``` – joseph22 Aug 01 '22 at 17:45
  • @joseph22, for me this work perfectly with `busybox` and display all the files. And why do you need vertical list? Seems like something is broken on your side. – Romeo Ninov Aug 01 '22 at 17:49
  • No need for a vertical list. Preference. – joseph22 Aug 01 '22 at 17:54
  • 1
    @joseph22, `ll` give you "long" listing which may be a problem, better use `-1` – Romeo Ninov Aug 01 '22 at 17:55
  • ```ls -1a *\.*\.* ``` shows 3 of 6 files. Seems like file ```e....``` is the most difficult to show. – joseph22 Aug 01 '22 at 18:17
  • @joseph22, I demonstrate display of all the files. So it seems like problem is in your machine. – Romeo Ninov Aug 01 '22 at 18:18
  • no need to use `\.` in a glob pattern, just `*.*.*` is enough because `.` is just special in a regex, not in a glob – phuclv Aug 02 '22 at 00:45
  • i am considering a move to Kubuntu 22.04.1 from Ubuntu 20.04.4 because with Ubuntu 20.04.4 i get divergent results with a file ending with a dot. Like file ```e....``` with GUI versus Terminal and file ```e....``` on usb vfat versus ext4. – joseph22 Aug 03 '22 at 02:27