Enviado em 26/09/2012 - 10:08h
Olá, eu estou tentando fazer o seguinte:Enviado em 27/09/2012 - 12:19h
#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE=1000 #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1; fi; if test -n "$2"; then SIZE=$2; fi; echo Finding Backup Files in $DIR bigger than $SIZE KB FILES=`find ${DIR} -size +${SIZE} |sed -e "s/ /?/g"` if test -n '$FILES'; then ls -l $FILES; else echo "No files found"; fi;
#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE=1000 #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1; fi; if test -n "$2"; then SIZE=$2; fi; echo Finding Backup Files in $DIR bigger than $SIZE KB FILES=$(find ${DIR} -size +${SIZE} |sed -e "s/ /?/g") if test -n '$FILES'; then ls -l $FILES; else echo "No files found"; fi;
Enviado em 27/09/2012 - 16:55h
Tu é pika, neguinho, mas se liga:Enviado em 27/09/2012 - 17:35h
#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE=1000 #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1; fi; if test -n "$2"; then SIZE=$2; fi; echo Finding Backup Files in $DIR bigger than $SIZE KB FILES=$(find ${DIR} -maxdepth 1 -size +${SIZE} |sed -e "s/ /?/g") if test -n '$FILES'; then ls -l $FILES; else echo "No files found"; fi;
Enviado em 27/09/2012 - 17:52h
boa, cara! O maxdepth resolveu a questão do recursivo.Enviado em 27/09/2012 - 18:15h
#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE=1000 #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1; fi; if test -n "$2"; then SIZE=$2; fi; echo Finding Backup Files in $DIR bigger than $SIZE KB FILES=$(find ${DIR} -maxdepth 1 -size +${SIZE}k |sed -e "s/ /?/g") if test -n "$FILES"; then ls -l $FILES; else echo "No files found"; fi;
Enviado em 28/09/2012 - 11:16h
Cara, Leandro, tentei com k(b), K(B), colado na variável, com espaço... nada funcionou. Continua retornando o resultado de "ls -l".Enviado em 28/09/2012 - 11:24h
Dei uma lida no manual do find e alterei a parte do size. O resultado é o mesmo, mas como quero esse script para ver arquivos realmente grandes, acho que assim fica mais visualmente limpo:#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE=40 #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1; fi; if test -n "$2"; then SIZE=$2; fi; echo Finding Backup Files in $DIR bigger than $SIZE MB FILES=$(find ${DIR} -maxdepth 1 -size +${SIZE}M |sed -e "s/ /?/g") if test -n '$FILES'; then ls -l $FILES; else echo "No files found"; fi;
Enviado em 28/09/2012 - 16:49h
Eu dei uma ligeira modificada no script. Teste este:#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE="40" #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1 fi if test -n "$2"; then SIZE=$2 fi echo "Finding Backup Files in $DIR bigger than $SIZE MB" FILES=$(find "$DIR" -maxdepth 1 -size +"$SIZE"M | sed -e "s/ /?/g") if test -n "$FILES" ; then ls -l $FILES else echo "No files found" fi exit 0
Enviado em 28/09/2012 - 17:36h
Parabéns Mlk! Acertou na mosca! Obrigado pela ajuda. Abcs.#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE="40" #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1 fi if test -n "$2"; then SIZE=$2 fi echo "Finding Backup Files in $DIR bigger than $SIZE MB" FILES=$(find "$DIR" -maxdepth 1 -size +"$SIZE"M | sed -e "s/ /?/g") if test -n "$FILES" ; then ls -l $FILES else echo "No files found" fi exit 0
#!/bin/sh #Valores padrões para comando sem argumento DIR="." SIZE="1" #Argumentos de diretorio e tamanho if test -n "$1"; then DIR=$1 fi if test -n "$2"; then SIZE=$2 fi echo "Finding Backup Files in $DIR bigger than $SIZE MB" FILES=$(find "$DIR" -maxdepth 1 -size +"$SIZE"M | sed -e "s/ /?/g") if test -n "$FILES" ; then echo "there are files to remove" rm -rv $FILES else echo "No files found" fi echo "Nothing else to do. Thanks for using me" exit 0
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
Como converter imagens PNG/JPEG para SVG em linha de comando
Fez porcaria no teu repositório Git? Aprenda a restaurar uma versão anterior do seu código!
Restaurando Fontes de Download do Hydra no Linux
Atualizando "na marra" o YT-DLP quando começa a dar erro de downloads
Como instalar o WPS com interface e corretor ortográfico em PT-BR no Arch Linux
Jogos baixados na Central de Aplicativos mas que não abrem (0)
Configuração de rede proxmox (2)