1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| $ cat employee.txt 101,John Doe,CEO 102,Jason Smith,IT Manager 103,Raj Reddy,Sysadmin 104,Anand Ram,Developer 105,Jane Miller,Sales Manager
$ sed 's/^[0-9][0-9][0-9]/[&]/g' employee.txt [101],John Doe,CEO [102],Jason Smith,IT Manager [103],Raj Reddy,Sysadmin [104],Anand Ram,Developer [105],Jane Miller,Sales Manager
$ sed 's/\([^,]*\).*/\1/g' employee.txt 101 102 103 104 105
$ sed 's/\([^,]*\),\([^,]*\),\([^,]*\).*/\1,\3/g' employee.txt 101,CEO 102,IT Manager 103,Sysadmin 104,Developer 105,Sales Manager
|