miércoles, 11 de agosto de 2021

remove first character first line sed -i linux

Sed stands for Stream Editor which parses text files and used for making textual transformations to a file. 

The command specified to Sed, is applied on the file line by line. 

sed [options]\'{command}\' [ file name] 

sed -i \'s/{old value}/{new value}/\'  [ file name ]


 #!/bin/bash


# current date;

today=`date '+%Y%m%d'`;


# replace 60 first character from string on file with a " ;

sed -i 's/............................................................./,\"/g' list_$today.txt;


# replace '.pdf' from string on file with a " ;

sed -i 's/\.pdf/\"/g' list_$today.txt;


# replace " with ';

sed -i "s/\"/'/g"  list_$today.txt;


# remove first character first line on file;

sed -i '1s/^.//'  list_$today.txt;



# update info with the file modified

mysql -u USER -pPASSWORD DATABASE -e "


UPDATE TABLE_1 SET pdf= 1 WHERE folio in ($( cat list_$today.txt )) and pdf = '';

UPDATE TABLE_2 SET pdf= 1 WHERE folio in ($( cat list_$today.txt )) and pdf = '';


"



No hay comentarios:

Publicar un comentario