Page 1 of 1

search and insert

PostPosted: Thu Aug 18, 2016 5:39 am
by Skaperen
i had a need for this today and ended up using a rather awkward solution. i think it could be done better with a relatively small python script. the command takes two strings and one or more files. search for the string in each file and insert the 2nd string after the found line in each file.

extras:

1. if '-r' or '-e' option given, do the search with the 1st string being a regexp ... or use -f to mean not a regexp.

2. preserve date, group and permissions. if run as root, also preserve ownership.

3. other features you think are useful.

Re: search and insert

PostPosted: Thu Aug 18, 2016 6:05 am
by micseydel