While I agree that a solution using
find(1) is much more elegant, you can also fall back to simple shell scripting to accomplish the same thing:
Code:
#!/bin/sh
for f in $(ls | grep foo) ; do
echo "cp $f /dest"
done
- Place the above code into a text file & execute as an argument to sh(1) or make the file executable through chmod(1).
- Once satisfied that the output constructs the needed command, remove echo & the double-quotes.