• This forum has a zero tolerance policy regarding spam. If you register here to publish advertising, your user account will be deleted without further questions.

bash: for directory listing

h00ch

Registered User
Hi,

folgendes Code-Schnipsel liefert nicht das gewünschte Resultat:

Code:
for file in "$( find /root/test -type d )"
do
  echo "1"
  echo "$file"
done

exit 0

Ausgabe:
Code:
1
/root/test
/root/test/test1
/root/test/test2

Gewünscht:
Code:
1
/root/test
1
/root/test/test1
1
/root/test/test2

Ich habe "Example 10-10." von Loops abgewandelt.

MfG, h00ch
 
duch die Anführungszeichen wird die Ausgabe von find zu einem Parameter, folglich wird die Schleife auch nur einmal durchlaufen. So sollte es gehen:
Code:
for file in $( find /root/test -type d )
do
  echo "1"
  echo "$file"
done

exit 0
 
Back
Top