Estoy con el dataset del Titanic y quiero aplicar varios cambios mediante sed o awk, pero quiero que tengan regex y que sean en varias líneas.
El dataset es así:
name,"gender","age","class","embarked","country","ticketno","fare","sibsp","parch","survived"
Abbing, Mr. Anthony,"male",42,"3rd","S","United States",5547,7.11,"0","0","no"
Abbott, Mr. Eugene Joseph,"male",13,"3rd","S","United States",2673,20.05,"0","2","no"
Abbott, Mr. Rossmore Edward,"male",16,"3rd","S","United States",2673,20.05,"1","1","no"
Abbott, Mrs. Rhoda Mary 'Rosa',"female",39,"3rd","S","England",2673,20.05,"1","1","yes"
Abelseth, Miss. Karen Marie,"female",16,"3rd","S","Norway",348125,7.13,"0","0","yes"
Abelseth, Mr. Olaus Jørgensen,"male",25,"crew","S","United States",348122,7.13,"0","0","yes"
Abelson, Mr. Samuel,"male",30,"2nd","C","France",3381,24,"1","0","no"
Abelson, Mrs. Hannah,"female",28,"2nd","C","France",3381,24,"1","0","yes"
Abi-Al-Munà , Mr. Nasif Qasim,"male",27,"3rd","C","Lebanon",2699,18.1509,"0","0","yes"
Abrahamsson, Mr. Abraham August Johannes,"male",20,"3rd","S","Finland",3101284,7.1806,"0","0","yes"
Quiero hacer un regex para hacer el cambio del campo "embarked" y lo planteo de esta forma:
sed -e 's/[a-zA-Z,.]*,[Mr|Mrs].[a-zA-Z]*,"[male|female]",[0-9][0-9],"[1st|2nd|3rd|crew]","C",/[a-zA-Z,.]*,[Mr|Mrs].[a-zA-Z]*,"[male|female]",[0-9][0-9],"[1st|2nd|3rd|crew]","Cherbourg",/g.' titanic.csv
Me da error al ejecutar sed: -e expresión #1, carácter 180: opción desconocida para `s'
Qué estoy haciendo mal?
Gracias.
[male]
no estás buscando "male", sino indicando que haya un carácter de entrem
,a
,l
oe
."male"|"female"
explicitamente en esa parte del regex? El mismo fallo lo cometo con[Mr.|Mrs.]
, no?sed -r 's/(una|otra)//'
debería funcionar. Fíjate en el-r
.-r
me da el error:sed: -e expresión #1, carácter 88: opción desconocida para `s'
. La expresión es:sed -r 's/[a-zA-Z,.]*,(Mr|Mrs).[a-zA-Z]*,"(male|female)",[0-9][0-9],"(1st|2nd|3rd|crew)","C",//"Cherbourg",/g.' titanic.csv
Ten en cuenta que quiero usar Regex completo. No voy bien así?/g.
. Di solamente/g
. También tienes una barra de más antes de "Cherbourg", es,/"Cherbourg",/g
.