S
S
SoAmazingWorld2014-07-30 13:00:25
linux
SoAmazingWorld, 2014-07-30 13:00:25

Bash Scripting: How to exclude folders from for-loop?

The question is as follows: how to exclude directories from for-loop.
For example, there is this script:

for x in *
do
sha1sum $x
done

How can I make the loop skip directories by and not try to apply hashing to them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tolik, 2014-07-30
@SoAmazingWorld

for x in *
do
if [ -f $x ]; then
sha1sum $x
fi
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question