Pages

vendredi 25 novembre 2011

insert some space in a specific position of a line of text

For given a line from the results of grep, we use awk to insert some space between the position of 130 and 131:

grep SX Sx_xxxxxxxxx92201M017xxx.lageos_coresta | awk '{printf("%s
%s\n",substr($0,0,130),substr($0,131))}'


---substr($0,0,130): $0 is the input string/text, 0 is the starting position, 130 is the ending position. This is to get the first 130 characters in the input string

---substr($0,131): 131 is the starting position. This is to get the substring starting from 131th column in the input string.

Aucun commentaire:

Enregistrer un commentaire