Por padrão, bash
não contém os arquivos de pontos, portanto, para remover tudo, menos os arquivos ocultos, em bash
, usando rm
:
rm *
Exemplo de saída:
~/tmp$ ls -la
total 8
drwxrwxr-x 2 user user 4096 giu 11 20:00 .
drwxr-xr-x 21 user user 4096 giu 11 08:26 ..
-rw-rw-r-- 1 user user 0 giu 11 20:00 .1
-rw-rw-r-- 1 user user 0 giu 11 20:00 2
-rw-rw-r-- 1 user user 0 giu 11 20:00 3
-rw-rw-r-- 1 user user 0 giu 11 20:00 4
-rw-rw-r-- 1 user user 0 giu 11 20:00 5
~/test$ rm *
~/tmp$ ls -la
total 8
drwxrwxr-x 2 user user 4096 giu 11 20:00 .
drwxr-xr-x 21 user user 4096 giu 11 08:26 ..
-rw-rw-r-- 1 user user 0 giu 11 20:00 .1
Para remover tudo, menos .gitkeep
em bash
, permitindo globbing para arquivos de pontos e usando rm
:
shopt -s dotglob
rm !(.gitkeep)
Exemplo de saída:
~/tmp$ ls -la
total 8
drwxrwxr-x 2 user user 4096 giu 11 20:19 .
drwxr-xr-x 21 user user 4096 giu 11 08:26 ..
-rw-rw-r-- 1 user user 0 giu 11 20:19 1
-rw-rw-r-- 1 user user 0 giu 11 20:19 2
-rw-rw-r-- 1 user user 0 giu 11 20:19 3
-rw-rw-r-- 1 user user 0 giu 11 20:19 4
-rw-rw-r-- 1 user user 0 giu 11 20:19 5
-rw-rw-r-- 1 user user 0 giu 11 20:19 .gitkeep
-rw-rw-r-- 1 user user 0 giu 11 20:19 .hidden
~/tmp$ shopt -s dotglob
~/tmp$ rm !(.gitkeep)
rm: cannot remove ‘.’: Is a directory
rm: cannot remove ‘..’: Is a directory
user@user-X550CL:~/tmp$ ls -la
total 8
drwxrwxr-x 2 user user 4096 giu 11 20:20 .
drwxr-xr-x 21 user user 4096 giu 11 08:26 ..
-rw-rw-r-- 1 user user 0 giu 11 20:19 .gitkeep