bash search and replace question
Hi
I need to achieve something very specific, and all the responses I find do not quite match my requirements. Therefore, if I am repeating a question I apologise. I am trying to import many many users from one server to another. I can automate the user creation, but I need to copy over the passwords. To achieve this I'm planning to copy the hash from /etc/shadow on the old server to the same file on the new one. I do not know the individual users' passwords from a plain text point of view, but I have confirmed that simply copying the hash over to the new shadow file maintains the password and the login works. So what I'm trying to do is this : I have a lookup list of usernames and hash's from the old server that looks like this : Quote:
I have a destination shadow file which might look like this : Quote:
And so, my solution would involve searching for each individual username in the destination shadow file, (username is specified by field 1 in my lookup list), and on that line replace the string "!!" with the correct password hash (hash specified by field 2 in my lookup list). I can pull out the two fields from my lookup list by doing something like : Quote:
I realise this is a very specific requirement, and there might be a better way to approach it altogether, but logically this seemed like a good solution. I'm just missing the scripting logic/commands. Any suggestions on this would be awesome, since I'm not much of a bash guru, and it's driving me slightly insane :) Many thanks in advance. Jess |
you can see a similar example here. Just change the field numbers around.
|
All times are GMT -5. The time now is 02:15 AM. |