空の名前でファイルを作成するには?

空の名前でファイルを作成するには?

方法はわかりませんが、空のファイル名でファイルを生成しましたが、そこにスペースがあるようです(理由は最後に説明します)。

chaouche@karabeela /mnt/ubuntu/storage $ ls
total 352K
drwx------  3 chaouche chaouche 4.0K Feb 12 11:00
drwxr-xr-x  4 chaouche chaouche 4.0K Apr 14 23:13 AUDIO
drwxr-xr-x  5 chaouche chaouche 4.0K Jul 20 22:25 BACKUPS
-rw-r--r--  1 chaouche chaouche 310K Jun 15 13:00 cv_yassine_chaouche_2012.pdf
drwxr-xr-x  2 chaouche chaouche 4.0K Jun 10 22:16 Mageia-3-i586-DVD
drwxr-xr-x  5 chaouche     1001 4.0K Oct 12  2012 MUSIQUE
drwxr-xr-x 15 chaouche chaouche 4.0K Oct 27  2012 PARISVIII
drwxr-xr-x  6 chaouche chaouche 4.0K Jun 12 18:33 SABAYON
drwxr-xr-x  5 chaouche chaouche 4.0K Jun 15 13:23 SIFTECH
drwxr-xr-x  5 chaouche chaouche 4.0K Feb  6 15:11 TOILES
drwxr-xr-x  4 chaouche chaouche 4.0K Jul 17 17:21 VIDEOS
chaouche@karabeela /mnt/ubuntu/storage $

私は#linuxからこのファイルを削除する方法を尋ね、誰かが他のすべてのファイルを邪魔にならない場所に移動し、タブ補完を使用することを提案しました。これは非常に興味深い動作を提供しました。

# with tab completion
chaouche@karabeela /mnt/ubuntu/storage $ ls /
total 45M
-rwxr-xr-x  1 chaouche chaouche  34M Jan 16  2013 inkscape-0.48.4-1-win32.exe
-rwxr-xr-x  1 chaouche chaouche 8.6M Feb  4 11:42 mypaint-1.0.0-win32-installer.exe
-rwxr-xr-x  1 chaouche chaouche 2.7M Jan 17  2013 pdftkb_setup.exe

# without tab completion, wrote "/" by hand
chaouche@karabeela /mnt/ubuntu/storage $ ls /
total 212K
-rw-r--r--   1 root root    0 Apr 15  2012 1
drwxr-xr-x   2 root root 4.0K Dec  9  2012 bin
drwxr-xr-x   3 root root 4.0K Jun 15 12:10 boot
-rw-------   1 root root  74K Jul  1  2011 dead.letter
drwxr-xr-x  19 root root 4.2K Jul 20 20:14 dev
drwxr-xr-x 117 root root  12K Jul 20 21:30 etc
drwxr-xr-x   4 root root 4.0K Jun 12 18:40 home
drwxr-xr-x   2 root root 4.0K Jun  8  2011 initrd
drwxr-xr-x  20 root root  12K Dec  9  2012 lib
drwx------   2 root root  16K Jun  7  2011 lost+found
drwxr-xr-x   4 root root 4.0K Jul  3 01:56 media
drwxr-xr-x   9 root root 4.0K Apr 15 00:06 mnt
drwxr-xr-x   8 root root 4.0K Jun 30 23:19 opt
dr-xr-xr-x 198 root root    0 Jun 15 13:10 proc
drwxr-x---  28 root root 4.0K Jul 20 21:42 root
drwxr-xr-x   2 root root  12K Dec  9  2012 sbin
drwxr-xr-x   2 root root 4.0K Apr  3  2011 srv
drwxr-xr-x  12 root root    0 Jun 15 13:10 sys
-rw-r--r--   1 root root    0 Jun 12 18:40 thisismageia
drwxrwxrwt  69 root root  36K Jul 20 22:04 tmp
drwxr-xr-x  14 root root 4.0K Nov  6  2011 usr
drwxr-xr-x  18 root root 4.0K Jul  2  2011 var
chaouche@karabeela /mnt/ubuntu/storage $

ファイル名にスペースが含まれている場合は、タブキーを押したときに\" "に変わりますが、そうではありません。

ベストアンサー1

名前が空のファイルを持つことはできません。あなたが持っているのは、名前が空白や印刷できない文字で構成されたファイルです。

ファイル名が何であるかを正確に表示するには、を実行してくださいLC_CTYPE=C ls -b。これにより、空白や印刷できない文字が8進エスケープに置き換えられます。たとえば、幅0の単一スペースを含む名前のファイルは\342\200\213

良い名前のファイルを除外するglobを使用してこのファイルを分離できます。たとえば、名前が文字で始まらないファイルを一覧表示できます。

chaouche@karabeela /mnt/ubuntu/storage $ ls -d [^A-Za-z]*

内容ではなくディレクトリ自体を一覧表示する-dオプションを忘れないでください。ls

ファイル名を合理的な名前に変更する必要があります。シェルの補完機能を使用するか、このファイルにのみ一致するglobを使用できます。

mv [^A-Za-z]* windows-programs

おすすめ記事