- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Removing an name from a file!
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
04-04-2003 07:38 AM
04-04-2003 07:38 AM
Right, I have a permissions file some lines are like this:
jbloggs[2]:rnash[12]:jdoe[1]
others like this:
jbloggs:rnash:jdoe
I have (after hours of trial and error) managed to add a new name based on one that already exists (the problem was including the [2] if necessary. The problem I now face is removal. Lets say I want to remove rnash from the file - how do I do this bearing in mind that ht name may appear as :rnash: :rnash[1]: or :rnash[24]:?
Thanks in advance for your help.
Ton
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 07:55 AM
04-04-2003 07:55 AM
Re: Removing an name from a file!
Try this
cat perms | sed 's/rnash\(\[[0-9][0-9]\]\)/ /g'
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 07:55 AM
04-04-2003 07:55 AM
Re: Removing an name from a file!
the easiest way is to create a temporary file, containing everything but "rnash". You can do that by e.g.:
# grep -v rnash
and then mv
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 08:00 AM
04-04-2003 08:00 AM
Re: Removing an name from a file!
Try this
sed 's/rnash.*://g' data
This will preserve the : seperators between the other fields after removing rnash entries.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 08:04 AM
04-04-2003 08:04 AM
Re: Removing an name from a file!
you can see the format though. Have a play. I'm finished for the weekend
enjoy everyone
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 08:20 AM
04-04-2003 08:20 AM
Re: Removing an name from a file!
Hope tha makes sense.
Thanks,
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 08:52 AM
04-04-2003 08:52 AM
Re: Removing an name from a file!
perl -p -i -e 's/:rnash[^:]*//g' yourfile
Will remove string ":rnhash" followed by any character up until (but not including) the next ":".
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 08:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 09:56 AM
04-04-2003 09:56 AM
Re: Removing an name from a file!
# p.awk - awk script
BEGIN{}
{
for (i=1;i<=NF;i++) {
if (substr($1,1,length(name)) != name ) {
printf ("%s:",$i);
}
}
}
END{}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
assuming abc.txt contains the following string -
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
jbloggs:ramd[3]:hello[245]:asfjdsf:sdflk:ramd[334]:end
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
the command line is:
awk -F: -v name=ramd -f p.awk abc.txt
the output is:
jbloggs:hello[245]:asfjdsf:sdflk:end
Just coz i like awk....
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 10:53 AM
04-04-2003 10:53 AM
Re: Removing an name from a file!
A simple approach where infile contains your first attachment:
1)put everyone on a separate line:
# tr ":" "\012"
2) remove all occurrences you do not like:
# grep ???v rnash infile_1 >infile_2
3) put the remaining back on a single line:
# tr ???\012??? ???:???
4) remove the extra colon at the end (ksh only):
# STRING=$( cat infile_3 )
# echo ${STRING%:} >outfile
now outfile should be without rnash ??? in any shape.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2003 12:36 AM
04-07-2003 12:36 AM
Re: Removing an name from a file!
Cheers,
Tony