首页 \ 问答 \ 批处理脚本在文本文件中搜索字符串;(Batch script to search strings in text file; echo string found or not found)

批处理脚本在文本文件中搜索字符串;(Batch script to search strings in text file; echo string found or not found)

我需要一个CMD脚本,它能够基于findtr命令来搜索文本文件,该命令有多个字符串可供搜索。


在这种情况下,我创建了一个包含命令结果的文本文件(kb.txt)

wmic qfe list

我需要的脚本将读取文件并使用findstr命令搜索它,如下所示:

findstr "kb3199321 kb3175631 kb3155567 kb3143345"

如果未找到该字符串,则会输出未找到的字符串。 对于那些已经找到的人也是如此。 输出示例:

kb3199321 not found
kb3175631 found
kb3155567 found
kb3143345 not found

脚本应该遍历所有字符串的findstr命令(不仅仅是上面列出的4个,它可能是几十到几百个),并且对于它们中的每个字符串,如果找到该字符串,则回显。


注意

如果findstr命令太有限(无法搜索超过一百个字符串),那么脚本应从另一个单独的文本文件(例如“searchfile.txt”)中读取所有字符串,然后搜索“ kb.txt“来查看它是否能够找到字符串,并回显与上面相同的想要的结果


I need a CMD script that is able to search through a text file based on a findstr command that has multiple strings in it to be searched for.


In this case, I have created a text file (kb.txt) that contains the result of the command:

wmic qfe list

The script I need will read the file and searches through it with the findstr command like:

findstr "kb3199321 kb3175631 kb3155567 kb3143345"

If the string is not found, it will output the string that is not found. The same goes for those that have been found. Example of output:

kb3199321 not found
kb3175631 found
kb3155567 found
kb3143345 not found

The script should loop through the findstr command for all its strings (not just the 4 listed above, it could be a few dozen to hundreds), and for each of them, echo if the string is found or not.


Note

If the findstr command is too limited (where it can't search through more than a hundred strings), then the script should read off all the strings from another separate text file (e.g. "searchfile.txt"), then search through the "kb.txt" to see if it is able to find the strings, and echo the same wanted results as above


原文:https://stackoverflow.com/questions/40857062
更新时间:2022-04-07 06:04

最满意答案

你可以试试iOS的facebook sdk。

  1. 对于页面中的展示帖子,您可以通过Facebook对象请求$ {pageId} / feed。 这样的事情。 这是页面对象

    [facebook requestWithGraphPath:@"pageId/feed" andDelegate:self];
    
  2. 推送通知,您必须通过选中相同的$ {pageId} / Feed来检查服务器中是否每2分钟有一个新的Feed。 如果$ {pageId} / Feed中有新帖子,您可以将内容推送给粉丝。

  3. 从iphone中的$ {pageId} / feed获取数据(这是一个post对象)后,您可以将它们存储到核心数据中。 post对象中有一个“喜欢”的字段供您订购。


You can try the facebook sdk for iOS.

  1. for show posts in the page, you can request a ${pageId}/feed via Facebook object. something like this. Here is the page object.

    [facebook requestWithGraphPath:@"pageId/feed" andDelegate:self];
    
  2. push notification, you have to check if there is a new feed in the page for maybe every 2 mins in your server by checking the same ${pageId}/feed. And if there is a new post in the ${pageId}/feed, you can push the content to your fans.

  3. After you get the data(which is a post object) from ${pageId}/feed in the iphone, you can store them into core data. There is a field "likes" in the post object for you to order by.

相关问答

更多
  • 只需2个步骤: 获得用户的“manage_pages”权限 通过拨打FB.api(/me/accounts)获取所有帐户信息 方式二,从Fql查询得到它: SELECT page_id, type from page_admin WHERE uid=me() page_admin文档在这里 Just 2 steps: get "manage_pages" permission from user Get all account information by calling FB.api(/me/accou ...
  • Facebook使用Bit.ly的服务来缩短他们网站的链接。 当拥有用户名的页面变成“ fb.me/ ”时,与Facebook相关的其他链接变成“ on.fb.me/***** ”。 要使用on.fb.me服务,只需使用您的Bit.ly帐户即可。 请注意,如果您将Bit.ly帐户上的默认链接缩短器从bit.ly更改为j.mp,则此服务将无法使用。 Facebook uses Bit.ly's services to shorten links from their site. While ...
  • 没有简单的方法可以做到这一点,因为帖子和广告之间没有任何关联。 最简单的方法可能是请求帐户的所有广告素材及其object_story_id: //act_/adcreatives?fields=object_story_id 然后请求帐户中的所有广告以及广告素材和参考是否匹配: //act_/ads?fields=id,creative There is no simple way to do this as there ...
  • 我正在寻找相同的功能。 我想你将不得不订阅以下事件并自己处理通知过程。 FB.Event.subscribe('comment.create', function() {} I am looking for the same feature. I think you would have to subscribe to the following event and handle the notification process yourself. FB.Event.subscribe('comment. ...
  • 你可以试试iOS的facebook sdk。 对于页面中的展示帖子,您可以通过Facebook对象请求$ {pageId} / feed。 这样的事情。 这是页面对象 。 [facebook requestWithGraphPath:@"pageId/feed" andDelegate:self]; 推送通知,您必须通过选中相同的$ {pageId} / Feed来检查服务器中是否每2分钟有一个新的Feed。 如果$ {pageId} / Feed中有新帖子,您可以将内容推送给粉丝。 从iphone中的$ ...
  • 通知只能发送,之后无法以任何方式访问。 没有API。 没有 没有 Notifications can only be sent, you cannot access them after that in any way. There is no API for it. No No
  • 您正在以错误的方式拨打电话,您必须提供其他parameters例如应用访问令牌,模板等,您的应用应该是一个canvas app 有关更多详细信息,请参阅开发人员网站上的Notifications API教程,他们详细说明了如何使用此API作为示例(非常简单) 此外,您正在发出GET请求(默认情况下)而不是POST (您必须明确提及该方法),这就是为什么而不是发布您只是得到结果。 代码示例 : FB.api('/RECEIPIENT_USERID/notifications', 'post', ...
  • 我已经尝试了fb对象调试器,结果是,og:标题丢失了,所以在我添加它之后就可以了。 https://developers.facebook.com/tools/debug/og/object/ 此外,它可能是一些fb缓存的问题(也可以通过从对象调试器获取新信息来解决) I've tried fb object debugger and turns out, that og:title is missing, so after I add it it works. https://developers.fac ...
  • 要“喜欢”一篇文章: 就像是: Facebook mFacebook = new Facebook(); mFacebook.request(THE_POST_ID + "/likes", parameters, "POST"); 要对帖子“发表评论” : Bundle parameters = new Bundle(); parameters.putString("message", edtComment.getText().toString()); mFacebook.request(THE_POST ...
  • 我得到了解决方案,我正在使用GET请求,而是使用POST请求 post_id/comments?message=Test Comment. 它将返回新的评论ID。 I got the solution, i was using GET request , instead use POST request post_id/comments?message=Test Comment. It will return the new comment ID.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)