Find the answer to your Linux question:
Results 1 to 3 of 3
I need some help with sed because im not so used to it. I want to insert a line into passwd and the input comes from a variable or shell ...
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    4

    Question execute shell command within sed

    I need some help with sed because im not so used to it.
    I want to insert a line into passwd and the input comes from a variable or shell command.

    the sed string is or should be:

    sed '/\+\:\:\:\:\:\:/ i\echo ${login}::${uid}:${gid}:${fullname}:${homedir}:$sh ell' $pwfile

    so my question is, how can i execute shell commands within the sed string/after the i\ ?
    would be great if anyone could help me or give me a hint.

    regards space

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    you can use an environmental varibale inside sed like
    sed s/one/`$PWD`/g sed.txt
    google with term "sed environment variable substitution"
    sed environment variable substitution - Google Search

    HTH
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Jun 2009
    Posts
    4

    Thumbs up

    thx, it's working

Posting Permissions

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