-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextract_vcfdata.sh
More file actions
executable file
·42 lines (42 loc) · 1.31 KB
/
extract_vcfdata.sh
File metadata and controls
executable file
·42 lines (42 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
START=`date +%s`
# Se crea el directorio destino donde se van a guardar los ficheros
DIR_DEST=$(pwd)/vcfs_`date +%d%m%Y`
mkdir $DIR_DEST
# Hay que asegurarse de que se trata de un fichero en formato UNIX
cp "$1" fileTemp
dos2unix -q fileTemp
NUM=0
while read linea; do
# Se obtiene el campo que identifica el valor de la línea
clave=`echo "$linea" | cut -d: -f1`
case $clave in
"BEGIN")
echo $linea > $DIR_DEST/temp
let NUM+=1
;;
"N")
echo $linea >> $DIR_DEST/temp
fileName="`echo $linea | cut -d: -f2`"
fileNameOrdered="`echo $fileName | cut -d\; -f2`"_"`echo $fileName | cut -d\; -f1`"
#echo "Nombre $NUM: $fileName | $fileNameOrdered"
;;
"N;ENCODING=QUOTED-PRINTABLE")
echo $linea >> $DIR_DEST/temp
fileName="`echo $linea | cut -d: -f2`"
fileNameOrdered="`echo $fileName | cut -d\; -f2`"_"`echo $fileName | cut -d\; -f1`"
#echo "Nombre $NUM: $fileName | $fileNameOrdered"
;;
"END")
echo $linea >> $DIR_DEST/temp
mv $DIR_DEST/temp "$DIR_DEST"/"$fileNameOrdered"
;;
*)
echo $linea >> $DIR_DEST/temp
;;
esac
done < fileTemp
rm -f fileTemp
END=`date +%s`
echo "Procesadas $NUM entradas en `expr $END - $START` segundos"
exit