РЕДАКТИРОВАТЬ: Не могли бы вы попробовать следовать с вашим отредактированным запросом.
awk '
BEGIN{
FS=","
}
FNR==1{
print
next
}
{
$1=substr($1,1,3)"-"substr($1,4,5)"-"substr($1,length($1))
split($3,array,"/")
$3=sprintf("%02d%02d%s",array[2],array[1],array[3])
gsub(/^-|\./,"",$NF)
$3=$3"000000"$NF
print $1,"NONREF",$3
}
' Input_file
Не могли бы вы попробовать следующие.
awk '
BEGIN{
FS=","
}
FNR==1{
print
next
}
{
$1=substr($1,1,3)"-"substr($1,4,5)"-"substr($1,length($1))
$2="0000"$2
split($3,array,"/")
$3=sprintf("%02d%02d%s",array[2],array[1],array[3])
gsub(/^-|\./,"",$NF)
$3=$3"000000"$NF
print $1,$2,$3
}
' Input_file
Объяснение: Добавление пояснения к приведенному выше коду.
awk ' ##Starting awk program here.
BEGIN{ ##Starting BEGIN section here.
FS="," ##Setting field separator as comma here.
}
FNR==1{ ##Checking condition if this is 1st line then do following.
print ##Printing current line here.
next ##next will skip all further statements from here.
}
{
$1=substr($1,1,3)"-"substr($1,4,5)"-"substr($1,length($1)) ##Setting $1 as sub-string(s) where 1st one starts from 1st character to till next 3 characters, 2nd one from 4th to till next 5 characters and so on.
$2="0000"$2 ##Adding 4 zeroes before value of $2.
split($3,array,"/") ##Splitting $3 into an array whose delimiter is /
$3=sprintf("%02d%02d%s",array[2],array[1],array[3]) ##Creating $3 with values of array[2],array[1] and array[3].
gsub(/^-|\./,"",$NF) ##Globally substituting starting - and DOT with NULL in last field of current line.
$3=$3"000000"$NF ##Setting value of $3 to $3 000000 and $NF here.
print $1,$2,$3 ##Printing $1,$2 and $3 values here.
}
' Input_file ##Mentioning Input_file name here, which we are passing to awk program.