博客
关于我
3剑客第10天练习题
阅读量:400 次
发布时间:2019-03-05

本文共 463 字,大约阅读时间需要 1 分钟。

排除过滤方法

在处理文件时,有时需要排除特定的内容。以下是常用的命令和工具:

  • grep -v:用于匹配文件内容,排除指定的文本。例如:
    grep -v "排除内容" 文件名
  • sed命令:使用sed脚本排除特定行。例如:
    sed -n ‘/排除内容/!p’ 文件名
  • awk脚本:通过条件判断排除匹配项。例如:
    awk ‘!/排除内容/{print}’ 文件名
  • 批量创建用户

    需要创建10个用户(oldboy01到oldboy10),并为每个用户设置随机密码。

    for i in {01..10}; do  useradd oldboy$i  echo $(cat /dev/urandom | od -x | head -n 1) | passwd --s $(whoami)done

    截取IP地址

    使用ifconfig命令获取IP地址,并格式化输出:

    echo ip:$(ifconfig | awk 'NR==2{print}’ | awk '{print $2}')

    这个命令会输出类似于:ip:192.168.5.101

    转载地址:http://ujhwz.baihongyu.com/

    你可能感兴趣的文章
    NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>
    npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
    查看>>
    npm和yarn的使用对比
    查看>>
    npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
    查看>>
    npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
    查看>>
    NR,NF,FNR
    查看>>
    nrf开发笔记一开发软件
    查看>>
    NSDateFormatter的替代方法
    查看>>
    NSOperation基本操作
    查看>>
    NSSet集合 无序的 不能重复的
    查看>>
    NT AUTHORITY\NETWORK SERVICE 权限问题
    查看>>
    ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
    查看>>
    nullnullHuge Pages
    查看>>
    numpy 用法
    查看>>
    Numpy如何使用np.umprod重写range函数中i的python
    查看>>
    oauth2-shiro 添加 redis 实现版本
    查看>>
    OAuth2.0_JWT令牌-生成令牌和校验令牌_Spring Security OAuth2.0认证授权---springcloud工作笔记148
    查看>>
    OAuth2.0_JWT令牌介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记147
    查看>>
    OAuth2.0_介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记137
    查看>>