0

I want to move all .jpg and .jpeg files whose size is more than 10 kb. The code below moves only jpg with size greater than 10 kb. All .jpeg files are moved regardless of the size.

#!/bin/bash

mkdir notmyprograms

cd testprog

for file in $(find -name "*.jpeg" -o -name "*.jpg" -a -size +10k)
do
mv $file /home/rayan-ali/Desktop/notmyprograms/
done
  • You should try http://shellcheck.net/ before asking for human assistance, it will point out https://mywiki.wooledge.org/BashFAQ/001 and [When to wrap quotes around a shell variable](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable). Other than that, do you have an actual question? – tripleee Mar 31 '22 at 05:49
  • @tripleee thanks dude the links really helped <3 – k201083 Muhammad Rayan Ali Mar 31 '22 at 05:55
  • You're welcome, but please don't call people "dude" when you obviously have to be guessing their gender. – tripleee Mar 31 '22 at 06:01
  • 1
    Your find expression "find -name "*.jpeg" -o -name "*.jpg" -a -size +10k" is parsed as find ( -name "*.jpeg" ) OR ( -name "*.jpg" AND -size +10k ) -- see e.g. [276574](https://unix.stackexchange.com/questions/276574/operator-precedence-in-a-find-command/276575#276575) for an example – ジョージ Mar 31 '22 at 06:15

0 Answers0