killasmurf86 said:How about
$ mv *.txt /some/path/
Which will move all *.txt files
killasmurf86 said:Code:for i in `ls`; do if [ `file -ib $i | awk '{print $1}'` == 'text/plain;' ]; then mv $i /some/path fi done
sh ./move.sh
[: application/x-empty: unexpected operator
[: video/x-unknown: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/plain: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/octet-stream: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/xml: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/plain: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/octet-stream: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/xml: unexpected operator
[: text/plain: unexpected operator
[: video/x-unknown: unexpected operator
[: text/plain: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/plain: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: application/x-not-regular-file: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
/home/narges #
for i in `ls`; do
if [ `file -ib $i | awk '{print $1}'` == 'text/plain;' ]; then
mv $i /home/narges/cod
fi
done
$ find . \! -iname "*rpm" -type f -print0 | xargs -0 -I {} mv {} /path/to/text/folder
killasmurf86 said:Fixed typo in my script
: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operator
awk: illegal field $(), name "i"
input record number 1, file
source line number 1
[: ==: unexpected operato
killasmurf86 said:Fixed typo in my script
killasmurf86 said:crap, $1 was corret, there was other issue
Code:for i in `ls`; do if [ `file -ib $i | sed 's/; .*//g'` = 'text/plain' ]; then mv $i /some/path fi done
Now this should really work.
move.sh" 5 lines, 117 characters
/home/Mostafa/code # sh ./move.sh
file: invalid option -- Ø
file: invalid option -- §
file: invalid option -- Ù
file: invalid option -- Â…
file: invalid option -- Ø
file: invalid option -- §
file: invalid option -- Ù
file: invalid option -- Â…
file: invalid option -- Û
file: invalid option -- Œ
file: invalid option -- Ù
file: invalid option -- ‡
file: unrecognized option `--88.jpg'
Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
file -C -m magicfiles
Try `file --help' for more information.
[: =: unexpected operator
file: invalid option -- Ø
file: invalid option -- §
file: invalid option -- Ù
file: invalid option -- Â…
file: invalid option -- Ø
file: invalid option -- §
file: invalid option -- Ù
file: invalid option -- Â…
file: invalid option -- Û
file: invalid option -- Œ
file: invalid option -- Ù
file: invalid option -- ‡
file: invalid option -- .
file: invalid option -- j
file: invalid option -- g
Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
file -C -m magicfiles
Try `file --help' for more information.
[: =: unexpected operator
[: text/plain: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
mv "${i}" /some/path
DutchDaemon said:You'll probably need to quote or curly-brace some variables, e.g.
Code:mv "${i}" /some/path
ile: invalid option -- g
Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
file -C -m magicfiles
Try `file --help' for more information.
[: =: unexpected operator
[: text/plain: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
[: cannot: unexpected operator
file -ib "${i}"
DutchDaemon said:The same goes for the file command ....Code:file -ib "${i}"
find . -depth 1 -type f | while read i; do if [ `file -ib "${i}" | sed 's/; .*//g'` = 'text/plain' ]; then mv "${i}" /some/path; fi; done
DutchDaemon said:Run this inside the directory.
Code:find . -depth 1 -type f | while read i; do if [ `file -ib "${i}" | sed 's/; .*//g'` = 'text/plain' ]; then mv "${i}" /some/path; fi; done
Adjust the "depth" to how far into subdirectories you need to go. If it's all in one directory, use -depth 1.
while: Expression Syntax.
DutchDaemon said:Type [cmd=]sh[/cmd] to get a different shell, and try again.
sh
%{%}%n%{%} %{%}%~%{%} %{%}[%!]%{%}
/usr/ports/net/hping
: text/x-c++: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/x-c++: unexpected operator
[: text/x-c++: unexpected operator
[: text/x-c++: unexpected operator
[: text/x-c++: unexpected operator
[: text/x-c: unexpected operator
[: text/plain: unexpected operator
[: text/x-c: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
[: text/x-c++: unexpected operator
[: text/plain: unexpected operator
[: text/x-c++: unexpected operator
^C%{%}%n%{%} %{%}%~%{%} %{%}[%!]%{%}