0

I'm trying to add a zero at the end of the data that start with 62018 (it will always start with 62018)

UNB+UNOA:1+5030917029608:14+5000119000006:14+070509:0850+620180001000200++INVOIC

any help would be appreciated.

Thank you
JG

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by masijade
0

sed -e 's/\+62018\([0-9]+\)\+\+/+62018\10++/' infile > outfile

it doesn't work at my side:

# sed -e 's/\+62018\([0-9]+\)\+\+/+62018\10++/' file
UNB+UNOA:1+5030917029608:14+5000119000006:14+070509:0850+62018000100020++INVOIC

@OP:try this

awk 'BEGIN{FS="+";OFS="+"}$6~/^62018/{ $6=$6"0"}{ print $0 }' file
0

it doesn't work at my side:

# sed -e 's/\+62018\([0-9]+\)\+\+/+62018\10++/' file
UNB+UNOA:1+5030917029608:14+5000119000006:14+070509:0850+62018000100020++INVOIC

@OP:try this

awk 'BEGIN{FS="+";OFS="+"}$6~/^62018/{ $6=$6"0"}{ print $0 }' file

Of course. "+" is only a valid regex character in perl. Sed doesn't recognize it as the "1 or more" function. So do like this instead:

# sed -e 's/+62018\([0-9]*\)++/+62018\10++/' infile > outfile
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.