随笔分类 - shell
摘要:${file:0:5}:提取最左边的5个字节:/dir1${file:5:5}:提取第5个字节右边的连续5个字节:/dir2 例子: pval=12345678 r=${pval:0:2} echo $r #12 r=${pval:2:2} echo $r #34
阅读全文
摘要:新建脚本,并命名为welcome.sh,将如下内容写入脚本中。#!/bin/bashchmod ugo+x welcome.shcd ~sudo apt-get updatesudo apt-get install cowsaysudo apt-get install fortunegit clon
阅读全文
摘要:ROOT=$(readlink -fn $(dirname $0)/.. )find $ROOT -not -wholename \*.tox/\* -and \( -name \*.sh -or -name \*rc -or -name functions\* \) -print0 | xargs
阅读全文
摘要:https://www.linuxidc.com/Linux/2017-08/146610.htm 1.3 csplit命令 split只能按行或按照大小进行切分,无法按段落切分。csplit是split的变体,功能更多,它主要是按指定上下文按段落分割文件。 csplit [OPTION]... F
阅读全文
摘要:#!/bin/bash# Copyright 2013 OpenStack Foundation## Licensed under the Apache License, Version 2.0 (the "License"); you may# not use this file except i
阅读全文
摘要:来自mount_volume.sh文件https://opendev.org/opendev/system-config DEVICE=$1 MOUNT_PATH=$2 FS_LABEL=$3 parted --script $DEVICE mklabel msdos mkpart primary
阅读全文
摘要:以下命令学习自https://opendev.org/opendev/system-config basename readlink declare -A x //bash 4.0版本后支持此功能 nc date timeout ➜ test readlink -f test.sh //输出文件的绝
阅读全文
摘要:括号 括号一般在命令替换的时候使用。 双括号 使用双括号,在比较过程中使用高级数学表达式 方括号 方括号定义了测试条件。 第一个方括号后和第二个方括号前都要加一个空格,否则会报错。 双方括号 双方括号提供了字符串比较的高级特性。 括号中可以定义一些正则表达式来匹配字符串 注意不是所有的shell都支
阅读全文