I am trying to use sed or awk command in linux but I not sure if it is possible to achieve the outcome I am looking for. Using other solutions like perl is also ok, needing somebody help me tell me if possible. My problem: Have 2 files 1. Main.php script to populate sample data to database 2. Updatednames.txt updated user names Main.php - has many fields that start same, only 3 need to be modified Main.php 1 text,Australia, #user country 2 text,john, #first name 3 text,doe, #surname 4 text,firstname.lastname@example.org #email 5 text,active, #user status Updatenames.txt bob smith email@example.com I wanting make script can scan main.php, when detect line 2 or comment at end line 2 then it replace text between commas ,john, with first word first line updatenames.txt Next it detect line 3 or comment at end line 3 and replace word between commas line 3 ,doe, with second word line 1 updatenames.txt and same logic for line 4 So final result in php file will be 1 text,Australia, #user country 2 text,bob, #first name 3 text,smith, #surname 4 text,firstname.lastname@example.org #email 5 text,active, #user status The best competitors for the job I thiking are sed or awk command in linux, can anybody help me achieve this or have better solution please?