AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1489872

CryptoTrader's questions

Martin Hope
CryptoTrader
Asked: 2021-10-21 10:08:14 +0800 CST

匹配我有足够能力负担的所有物品。简单的正则表达式

  • -2

参加一个自我指导的 linux 教程,我一直对此感到困惑

我的输出一直包括“时钟 15”,请帮忙

#!/bin/sh
#comment single RegEx to match all of the items that you have enough rupees 
sed '1d' hw0207.txt | grep -v [2-9][0-9]
#comment grep will filter all numbers greater than 12, -v represents not
#comment first sed was to remove first line

正则表达式匹配方向

我正在尝试编写一个正则表达式来匹配您有足够卢比的所有项目。不要只匹配线,你应该匹配你能负担得起的线,这样如果价格发生变化,答案仍然是正确的。你只有 12 卢比,如果你想买更多的东西,你需要变得更富有一点。

Input file (hw0207.txt) Expected output of script
item cost
lamp oil 5
rope 10
clock 15
bombs 20
regex
  • 1 个回答
  • 139 Views
Martin Hope
CryptoTrader
Asked: 2021-10-20 16:58:19 +0800 CST

正则表达式匹配访问某个端口和特定数据包的行

  • 0

Linux 新手,我可以让它工作的唯一方法是使用 awk 命令,不幸的是,主要方向指定不使用 awk。

这就是我得到的

#!/bin/sh
#comment Write a single RegEx to match the lines that access port 22 and only those packets
grep '\s22\s' hw0206.txt | awk {'print $4'}
#comment grep returns the whole line with matched string
#comment \s22\s regular expression to match any string containing 22 preceded or succeeded by white space

指示

编写一个正则表达式来匹配访问端口 22 的行并且只匹配那些数据包,然后返回 IP 地址

Input file (hw0206.txt) Expected output of script
date time protocol ip-address port packet-size
2022-02-21 19:22:19 TCP 22.101.2.24 22 24
2018-22-22 02:25:12 UDP 10.221.7.22 2135 222
2200-05-22 22:26:22 UDP 22.122.6.62 2160 22
2012-22-20 15:43:22 TCP 10.121.7.222 22 122
1228-02-10 02:22:02 UDP 22.102.2.62 2089 22 
date time protocol ip-address port packet-size
2022-02-21 19:22:19 TCP 22.101.2.24 22 24
2018-22-22 02:25:12 UDP 10.221.7.22 2135 222
2200-05-22 22:26:22 UDP 22.122.6.62 2160 22
2012-22-20 15:43:22 TCP 10.121.7.222 23 122
1228-02-10 02:22:02 TCP 22.102.2.62 22 22
2100-05-25 21:26:22 UDP 22.112.63.62 2122 22
regex
  • 1 个回答
  • 284 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve