- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- some shell script or commands
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
Discussions
Discussions
Forums
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
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-01-2009 11:18 AM
тАО04-01-2009 11:18 AM
We have a text file "test1" containing both "required" and "un-required" server listing.
We created another text file "test2" from above containing only "un-required" server listing.
This test1 is a large file containing hundreds of server names listing.
Now i want to remove un-required servers from file test1.
Can anyone suggest some quick way to do it ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 11:23 AM
тАО04-01-2009 11:23 AM
Re: some shell script or commands
required server1
un-required serverabc
required serverxxx
un-required node123
Then you could:
cat test1 | grep -v "un-required" > test.new
Just a very very quick thought,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 11:41 AM
тАО04-01-2009 11:41 AM
Re: some shell script or commands
grep -v -f test2 test1 > newfile
What this does:
-v - output non-matching strings
-f test2 - use the patterns in this file
See the grep man page for more information.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 08:24 PM
тАО04-01-2009 08:24 PM
Re: some shell script or commands
See the example below
[suraj@rspc521 tmp]# cat srvlist
server1
server2
server3
server4
server5
server6
server7
server8
server9
[suraj@rspc521 tmp]# cat unreqlist
server2
server3
server5
server8
server9
[suraj@rspc521 tmp]# diff srvlist unreclist
1d0
< server1
4d2
< server4
6,7d3
< server6
< server7
The output is your required servers list.
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 04:32 AM
тАО04-02-2009 04:32 AM
Re: some shell script or commands
it depends upon how the text is in the file to a certain extent?
if for example you have them organised into columns of data, and all the un-required ones are in one or two coloumns then this could be achieved by something like this
example test file
required unrequired sorted
server1 server2 server5
server3 server4 server7
then we could extract the other two columns of data into another file
#awk '{print $1,$3,}' test > test3
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 04:46 AM
тАО04-02-2009 04:46 AM
SolutionYour file formats would help provide an appropriate solution.
If the files are sorted, and, for example, look like:
# cat file1
server1
server2
server3
server4
server5
server6
# cat file2
server2
server4
server6
...then:
# comm -23 file1 file2
server1
server3
server5
Regards!
...JRF...
- Tags:
- comm