Solved

Basic command UNIX command or script

Posted on 2013-01-31
4
391 Views
Last Modified: 2013-01-31
I have a flat file (fileA) with a list of server names. And I have another file (fileB) with a list of server names plus system accounts. I want every line in fileB that its server is not referenced in fileA to be removed. fileB has hundreds of more server names than what is listed in fileA. I need to only have the server names listed in fileA to be in fileB. And of course, do not to change any of the information after the server name in fileB. Please help and let me know if you need me to clarify anything.

Sample of fileA:

serverA
serverB
serverC
serverD
etc...

Sameple of fileB:

serverA:adm
serverA:bin
serverA:root
serverB:adm
serverB:bin
etc...
0
Comment
Question by:AIX25
4 Comments
 
LVL 12

Expert Comment

by:tel2
ID: 38841784
Hi AIX25,

Are both files already sorted alphanumerically, as they appear to be in the example?
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 250 total points
ID: 38841788
grep -f fileA fileB > resultfile
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 250 total points
ID: 38841794
try this

grep -f fileA fileB > newfile

the file newfile should have the relevant lines you need
0
 

Author Closing Comment

by:AIX25
ID: 38842016
They were answered minutes of each other. Thank you both!!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question