Remove special character from csv file using bash -


i have csv file in first([) , second last column (]) contain special character. example given below

col1      col2      col3      ..... coln-1   coln   [number   number    number    ..... number]  number 

i want remove [ first , ] second last column using bash script

with sed 's/]//g' file, can remove ]. have error [ same statement.

your approach sed sound. need know [ , ] special characters in (all flavors of) regular expressions, therefore need escaping backslashes. , name choice of 2 characters, […] used, so:

sed 's/[\[\]]//g' test.csv 

this, however, can done quicker using tr can remove given characters:

tr -d '[]' < test.csv > test2.csv 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -