Loop over files (Bash): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 30: | Regel 30: | ||
done | done | ||
</pre> | </pre> | ||
+ | |||
+ | == See also == | ||
+ | |||
+ | * [[Ln (Linux)]] | ||
== Sources == | == Sources == |
Versie van 8 aug 2022 09:26
This is cool: You can loop over files in a directory and do stuff with it!
Examples
Start simple:
#!/bin/bash cd ~/images-tmp for file in * do echo "File name: $file" done
Create links to all files in this folder, and put those links in another folder:
for file in *.jpg do source="${PWD}/${file}" link="/var/www/media.example.com/tmp2/$file" echo " Path+file: $source - Destination: $link" ln -s "$source" "$link" done