Find the answer to your Linux question:
Results 1 to 2 of 2
Hi Everybody, I want to add some data at the end of a line in a file.. For example: contents of my /etc/group file are: nobody::60001: noaccess::60002: nogroup::65534: nms::2500:nms1,nms2,nms3,nms4 ctxadm::55000: ...
  1. #1
    Linux Newbie
    Join Date
    Jul 2004
    Posts
    143

    adding some data at the end of a line

    Hi Everybody,

    I want to add some data at the end of a line in a file..
    For example:
    contents of my /etc/group file are:

    nobody::60001:
    noaccess::60002:
    nogroup::65534:
    nms::2500:nms1,nms2,nms3,nms4
    ctxadm::55000:
    sybase::202:

    Here I want to add nms5 in nms group, means at the end of line.
    How can I achieve this.
    Please help me.

    Thanks Inadvance,
    Mummaneni.

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    With awk:

    Code:
    awk '/nms:/{print $0",nms5";next}{print}' /etc/group > temp_file
    mv temp_file /etc/group
    Regards

Posting Permissions

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