We also need to make sure that a human can check the results.

FOLDERLIST="folder1 folder2 folder3" FILELIST="file1file2file3file4.db" cd /... MYLINE=`cat myline.txt` for FOLDER in $FOLDERLIST do for FILE in $FILELIST do cp $FOLDER/$FILE workfile sed "/Serial number/ s/.*/$MYLINE/" workfile Karel's post is good, but assumes the file list is exactly the same for each folder, and also that you are prepared to type "a couple of hundred" names into FILELIST.

I'm just a bit lazier than that." id="ctl00_m_m_i_ctl00_gr_ctl05_bestanswerbody" class="textarea-bestanswerhidden" name="bestanswerbody" answerbody Id="3984181" / Sorry, the thread is headed "Incrementing a bind serial number".

I assumed you wanted every such serial number to be, well, incremented - i.e. If you want them all set to the same value, or set to consecutive unique values from some base value, that's not hard to do either. Karel's post is good, but assumes the file list is exactly the same for each folder, and also that you are prepared to type "a couple of hundred" names into FILELIST. OK, there can be no universally general solution, so we need some constraints.

I see they are random and probably sparse, but this does not guarantee there could not be some overlap between old and new numbers. You might want to test this in a safe directory, or take a tar of the original files in case of accidents.

function Fix (f, Local, j, n, X) { while ((getline < f) > 0) { if ($0 ~ re Ser) $1 = $1 + 1; X [++n] = $0; } close (f); for (j = 1; j <= n; j++) print X [j] > f; close (f); } { Fix( $0); } ' ls *| awk "${AWK}" OK.

I assume the number of folders is not too high, otherwise you will need an outer loop to call the below script for each folder.The main script has to run in the folder1 etc, so to do all the folders, you would get to the directory above all the folders and do this on the command line: Are you sure that adding 1 to each serial number is safe? Awk reads each file, adjusts the serials, and re-writes the file. - excuse the pun :) I need to replace the serial number on a couple of hundred documents each within their own subdirectory./../folder1/file1/../folder1/file2/../folder1/file3/../folder2/file1/../folder2/file2/../folder2/file3these are bind dns records. These files all have different serial numbers, but consistent placement.i want to run a script that with " search for line # " and replace with " my new text line. the serial number are random so I am having issues matching numbers.sample file below; $TTL 28800 ; ; internal DNS ; @ IN SOA ( 2006020701 ; Serial number 10800 ; Refresh every 3 hours 3600 ; Retry every hour 604800 ; Expire every 7 days 86400 ) ; Min TTL of 1 day so basically i want to grep or awk or sed line 6 with right ? any insight or references you could provide me with would be appreciated thanks -j Are you sure that adding 1 to each serial number is safe? Awk reads each file, adjusts the serials, and re-writes the file.