- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script question !
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
тАО06-06-2004 11:36 PM
тАО06-06-2004 11:36 PM
I have a file (name.txt) with list of names
(one name in line) ,
i want to check if any name exist in other file
(name.log ).
I know it's a play with grep,awk,cut ..
any ideas ?
BYE.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2004 11:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2004 11:47 PM
тАО06-06-2004 11:47 PM
Re: Script question !
Try this:
FILES_LOG=name.log
FILES_TXT=`cat name.txt`
for FILE_TO_CHK in $FILES_TXT
do
FOUND=`grep $FILE_TO_CHK $FILES_TXT|wc -w`
if ["$FOUND" ! = "0" ]
then
echo "File $FILE_TO_CHK found into $FILES_LOG"
fi
done
If you need an exact name search try with "grep -x" option.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2004 11:48 PM
тАО06-06-2004 11:48 PM
Re: Script question !
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2004 11:53 PM
тАО06-06-2004 11:53 PM
Re: Script question !
Now THAT is a new one on me, thanks a lot.
No points for this post please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2004 11:59 PM
тАО06-06-2004 11:59 PM
Re: Script question !
And if you install GNU's grep, you'll find that it can do even more incredible things.
"grep" & "find" are a systems administrator's best friends.
and with the pattern file (named.txt) you can do cool things like "^someword" or "someword$" or "[Tt]hat [Cc]at in a [Hh]at"....
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2004 06:10 PM
тАО06-07-2004 06:10 PM
Re: Script question !
The -l option will report the position(in decimal) in the file where the difference occurred.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2004 06:34 PM
тАО06-07-2004 06:34 PM
Re: Script question !
# grep -f name.txt -w name.log
will grep on WORD base, which means that if file.txt contains 'oo.c', harry's grep will also match 'foo.c', but the -w version will not, it will only match the 'oo.c'
this is exceptionally better if you consider file names as 'name.c.org' and 'blah.foo.sav' in the log
Enjoy, Have FUN! H.Merijn [ who would use perl himself ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2004 09:59 PM
тАО06-07-2004 09:59 PM
Re: Script question !
Sanjay your answer was simple and suitable for my needs .
BYE.