Requerimento
Col1 , Col2 , Col3 , Col4
1 , a:/b/c/abc.txt , f:/b/c/abc1.txt , a:/b/c/abc6.txt
2 , b:/bd/a/s/3/d/mon.dat , g:/b/c/abc 2.txt, b:/b/c/ab7.txt
3 , c:/j/h/4/u/y/d/m/ttt.dat, h:/b/c/abc 3.txt, c:/b/c/abc 8.txt
4 , c:/j/h/4/test1.msg , i:/b/c/abc4.txt , d:/b/c/abc 9.txt
5 , d:/iasa/dda/dia/yyy.dat , j:/b/c/abc5.txt , e:/b/c/abc 10.txt
Esperar O/P
Col1 , Col2 , Col3 , Col4
1 , abc.txt , abc1.txt , abc6.txt
2 , mon.dat , abc2.txt , abc7.txt
3 , ttt.dat , abc3.txt , abc8.txt
4 , test1.msg , abc4.txt , abc9.txt
5 , yyy.dat , abc5.txt , abc10.txt
Responder1
Como não consegui inferir nenhum sistema na distribuição do espaço, apenas adivinhei alguma formatação. Fique à vontade para adaptar ao seu gosto.
awk -F, '{gsub (/ |\r/, ""); printf "%-4s ", $1; for (i=2; i<=NF; i++) {n=split($i, T, "/"); printf ", %-10s ", T[n]} printf RS}' OFS=, file
Col1 , Col2 , Col3 , Col4
1 , abc.txt , abc1.txt , abc6.txt
2 , mon.dat , abc2.txt , ab7.txt
3 , ttt.dat , abc3.txt , abc8.txt
4 , test1.msg , abc4.txt , abc9.txt
5 , yyy.dat , abc5.txt , abc10.txt
Responder2
Usando sed
e column
:
$ sed 's/ //g; s/,[^,]*\//,/g; s/,/ , /g' file | column -t
Col1 , Col2 , Col3 , Col4
1 , abc.txt , abc1.txt , abc6.txt
2 , mon.dat , abc2.txt , ab7.txt
3 , ttt.dat , abc3.txt , abc8.txt
4 , test1.msg , abc4.txt , abc9.txt
5 , yyy.dat , abc5.txt , abc10.txt
- substitua todos os caracteres de espaço por uma string vazia
- substitua tudo
,
seguido por não-,
caracteres seguido por/
um,
- substitua tudo
,
por,
- imprima bastante a saída como tabela com
column