Jak rozebrać prowadzenie"./ "in unix"find"? [zamknięte]

find . -type f -print

Drukuje

./file1
./file2
./file3

Dowolny sposób na wydruk

file1
file2
file3

?

Author: breadjesus, 2010-04-08

4 answers

Jeśli są tylko w bieżącym katalogu

find * -type f -print

Tego właśnie chcesz?
 33
Author: Tim Green,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-04-07 22:57:38

Znajdź tylko zwykłe pliki w bieżącym katalogu i wydrukuj je bez prefiksu " ./":

find -type f -printf '%P\n'

From Man find, description of -printf format:

%P nazwa pliku z nazwą argumentu wiersza poleceń, pod którym został znaleziony usunięty.

 171
Author: Ilia K.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-06-15 10:44:23

Użyj sed

find . | sed "s|^\./||"
 37
Author: Lie Ryan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-04-07 22:57:41

Może być krótszy

find * -type f
 10
Author: ghostdog74,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-04-07 23:45:48