I have a file composed by lines like these ones:
199240050;0180209199240050;0
199240241;0180209199240241;0
199240207;0180209199240207;0
199240400;0180209199240400;0
I should replace last number with "Active" if it is "0", Or "Inactive" if it is "1".
I've tried with sed
but the occurrence of ";0" in the middle of the line gets changed too.
It should be used in a linux bash script.
I tried the solution given by DopeGhoti but it fails:
$ sed 's/0$/active/;s/1$/inactive/' myLines.txt
800600346 078136521 active
While the format of the input file should not change.
The second solution appends ";active" at the end, without replacing:
$ awk -F\; 'BEGIN {OFS=";"} { if( $3 == 1 ) { print $1,$2,"inactive" } else { print $1,$2,"active" } }' myLines.txt
800010654 0295445503 0;;active
And George Vasiliou's also fails:
$ awk '$NF?$NF="active":$NF="inactive"' FS=';' OFS=';' myLines.txt
active
active
active
active
\r
line endings ??