HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- please help
Operating System - HP-UX
1838240
Members
3456
Online
110125
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2001 07:18 PM
09-10-2001 07:18 PM
please help
data_1:1a:2b:3c:4d:5e:6f:7g:8h:9i:10j:
data_1_th:11A:12B:13C:14D:15E:16F:17G:18H:19I:20J:
assuming "data_1" and "data_1_th" is group name and 1a,2b....11A,11B...are the member of "data_1" and "data_1_th" respectively.
What I need now is to grep the group name and once the group name was grep I need to go to the last entry of the of the particular group and place a new entry there and ends with ":". All I need now is to grep the correct group name and remember that the group is a continous data and it is not fixed! Please advise. Thanks in advance.
data_1_th:11A:12B:13C:14D:15E:16F:17G:18H:19I:20J:
assuming "data_1" and "data_1_th" is group name and 1a,2b....11A,11B...are the member of "data_1" and "data_1_th" respectively.
What I need now is to grep the group name and once the group name was grep I need to go to the last entry of the of the particular group and place a new entry there and ends with ":". All I need now is to grep the correct group name and remember that the group is a continous data and it is not fixed! Please advise. Thanks in advance.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2001 11:30 PM
09-10-2001 11:30 PM
Re: please help
Hi Ken,
You could use sed in a script:
#!/bin/sh
sed "s/\(^$1:.*\)/\1$2:/" yourfile > yourfile.new
mv yourfile.new yourfile
run the script using:
yourscript.sh group new_entry
Or are you saying that data_1 and data_1_th are related and can only have 10 entries per line?
Rgds, Robin.
You could use sed in a script:
#!/bin/sh
sed "s/\(^$1:.*\)/\1$2:/" yourfile > yourfile.new
mv yourfile.new yourfile
run the script using:
yourscript.sh group new_entry
Or are you saying that data_1 and data_1_th are related and can only have 10 entries per line?
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2001 02:53 AM
09-11-2001 02:53 AM
Re: please help
1 - to grep data_1 & not get data_1_th use
grep ^data_1:
2 - to write you a script I would use awk
#!/usr/bin/ksh
file=group-file
echo "Input user to be added ==>\c"
read user
echo "Input group for user to be added to ==>\c"
read group
awk -F":" '$1==GROUP { for (i=1; i<=NF; i=i+1) printf "%s:", $i ; printf "%s:\n", USER } $1!=GROUP { for (i=1; i<=NF-1; i=i+1)
printf "%s:", $i ; printf "%s:\n", $NF } ' USER=$user GROUP=$group $file > $file.tmp
mv $file.tmp $file
** PLEASE NOTE ** The group file you have listed above will NOT be /etc/group, as this has a totally different format. If you do mean this file then the script needs to be modified!
Tim
grep ^data_1:
2 - to write you a script I would use awk
#!/usr/bin/ksh
file=group-file
echo "Input user to be added ==>\c"
read user
echo "Input group for user to be added to ==>\c"
read group
awk -F":" '$1==GROUP { for (i=1; i<=NF; i=i+1) printf "%s:", $i ; printf "%s:\n", USER } $1!=GROUP { for (i=1; i<=NF-1; i=i+1)
printf "%s:", $i ; printf "%s:\n", $NF } ' USER=$user GROUP=$group $file > $file.tmp
mv $file.tmp $file
** PLEASE NOTE ** The group file you have listed above will NOT be /etc/group, as this has a totally different format. If you do mean this file then the script needs to be modified!
Tim
-
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP