Hi,
I have this file:
Helene;/home/home.html;24/02/04 14:16:09;oldcomment
Helene;/home/home.gif;24/02/04 14:16:09;oldcomment
With this code, I want to change the comment (last field of the record), to a new comment specified by the user.
variable="Helene"
awk -F';' ' { if( $1 ~/'${variable}'/ ){
print "Please enter a comment for this record: " >"/dev/tty"
print $0 > "/dev/tty"
getline newcomment < "/dev/tty"
$5=newcomment
print $0 }
} ' myFile > tmpFile
This is the result:
Helene /home/home.html 24/02/04 14:16:09 newcomment1
Helene /home/home.gif 24/02/04 14:16:09 newcomment1
Where is my field separator going??
