Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    substitution with sed

    Hi everybody,

    I have users' home directories under /home directory.
    Now I want to move home directories from /home to /home/users/
    For that I need to modify /etc/passwd

    So I need to replace /home/user1 to /home/users/user1 in /etc/passwd
    How can I do this by using sed
    Please suggest me.


  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    First, backup your existing /etc/passwd file in case something messes up.

    Anyway, the sed command would be:
    sed --in-place -e 's/\/home/\/home\/users/' /etc/passwd
    The '--in-place' option modifies the file right there. The regex will replace every instance of '/home' with '/home/users'.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts