ich möchte eine CVS-Datei zeilenweise durchsuchen und jeweils die fünfte Stelle (spaltenweise mit cut getrennt) an den Anfang jeder Zeile schreiben.
Ausgangsdatei:
Code: Alles auswählen
"c","b","d","a","mail1"
"c","b","b","a","mail2"
"c","b","b","a","mail3"
"c","b","d","a","mail4"
Code: Alles auswählen
"mail1"."c","b","d","a","mail1"
"mail2","c","b","b","a","mail2"
"mail3","c","b","b","a","mail3"
"mail4","c","b","d","a","mail4"
Code: Alles auswählen
while read datei1; do
mail=`echo $datei1 | cut -d "," -f5`
sed -e "s/^/$mail,/g" mail.csv > result.csv
done < mail.csv