gsklee
gsklee

Reputation: 4944

Bash Script: Perform certain actions on files of certain extension inside a certain directory?

How do I write a Bash script that, will select all files inside ~/test with a .css extension, so I can pipe them one by one into further actions?

Upvotes: 0

Views: 2170

Answers (1)

Prince John Wesley
Prince John Wesley

Reputation: 63708

#!/bin/bash
for f in ~/test/*.css
do
# your command 'cmd'
   cmd "$f"
done

To process a command for every .css files in one line, try like this:

find ~/test -type f -name '*.css' -execdir cmd {} \+

Upvotes: 1

Related Questions