Created
January 12, 2016 18:22
-
-
Save asfelix/ca3e3c650599e9c8d8b0 to your computer and use it in GitHub Desktop.
script para filtrar apenas determinada linhas de um conjunto de arquivos para montagem de relatório.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| destfile=/home/user/pedidos/filtro.txt; | |
| touch --date "2015-10-01 00:00:00" /tmp/start | |
| array=($(find /home/user/pedidos/2*.txt -type f -newer /tmp/start |sort)) | |
| n=${#array[@]}; | |
| b=1 | |
| for ((x=0; x < $n; x++)); do | |
| echo "PEDIDO NÚMERO: " $(($x + $b)) >> "$destfile" | |
| echo $(sed -n 7' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 8' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 11' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 12' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 14' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 30' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 31' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 32' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 40' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 41' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 42' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 43' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 44' p;' ${array[$x]}) >> "$destfile" | |
| echo $(sed -n 45' p;' ${array[$x]}) >> "$destfile" | |
| echo "###############################################################################" >> "$destfile" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment