Skip to content

Instantly share code, notes, and snippets.

@krystofl
Created August 8, 2018 21:08
Show Gist options
  • Save krystofl/9f6d2b88cf2a7e98270a60956028ad1e to your computer and use it in GitHub Desktop.
Save krystofl/9f6d2b88cf2a7e98270a60956028ad1e to your computer and use it in GitHub Desktop.
Simple shell script to show how to get a list of files and perform some action on all of them
#!/bin/bash
# Simple script to show how to get a list of files in a directory,
# and perform some action on all of them
# get the list of all the files we want to use
files=$(ls -1 *.txt)
# print list of all of them
# echo ${files[@]}
# infinite loop
# Ctrl + C to exit
while true; do
# do something to each one
for file in $files; do
echo $file
done
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment