Reputation: 21
I have many files with different file extensions,so i want to copy all except
".txt"
to another directory.
I tried below command to find all possible files with different file extensions except ".txt"
ls -lrt /home/updatet/test/ -I "*.txt"
and to copy
ls -1 /home/updatet/test/ | xargs cp {} demo/
Upvotes: 1
Views: 918
Reputation: 295638
See http://wiki.bash-hackers.org/syntax/pattern#extended_pattern_language for documentation
shopt -s extglob
cp /home/updatet/test/!(*.txt) demo/
for f in /home/updatet/test/*; do
case $f in
*.txt) :;;
*) cp "$f" demo/ ;;
esac
done
Upvotes: 1