Posts

Showing posts from January 11, 2019

Unix - Remove Leading/Trailing Spaces (Column Wise)

Image
0 I have text lines like these below: P, 123456 ,01,A,H, 123456 ,123456 123456 ,, P,123456 ,01,A,H, 123456, 123456 123456,, P, 123456,01,A,H,123456 ,123456 123456 ,, P, 123456,01,A,H, 123456, 123456 123456,, P,123456 ,01,A,H,123456 ,123456 123456 ,, I want them to be like below: P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, Requirements: Remove all leading & trailing spaces from 2,6,7 column only Values in 7th Column should remain separated by single space only Research: I have tried many combinations with awk , sed , tr but could not succeed according to my requirements. I would like to have a preferable solution in awk , s