Loop over files (Bash)
Versie door Jeroen Strompf (overleg | bijdragen) op 8 aug 2022 om 08: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