首页 > TAG信息列表 > macname

shell 解压当前目录所有zip文件

code macname@MacdeMacBook-Pro zipfiles % cat test.sh #!/bin/bash ZIP_FILES=$(ls *.zip) for zip_file in $ZIP_FILES; do unzip $zip_file done macname@MacdeMacBook-Pro zipfiles %                

python3 并发编程

多进程 macname@MacdeMacBook-Pro Desktop % macname@MacdeMacBook-Pro Desktop % macname@MacdeMacBook-Pro Desktop % python3 test.py main test 0 test 0 test 1 test 1 test 2 test 2 test 3 test 3 test 4 test 4 test 5 test 5 test 6 test 6 test 7 test 7 test 8 tes

sed 字符串替换

content macname@localhost Desktop % macname@localhost Desktop % cat ddd This is a test of the test script. This is the second test of the test script. macname@localhost Desktop %   #在行中替换文本 macname@localhost Desktop % sed 's/test/trial/' ddd

shell 获取数组的长度

code macname@localhost Desktop % cat test.sh my_array[0]=A my_array[1]=B my_array[2]=C my_array[3]=D echo "数组元素个数为: ${#my_array[*]}" echo "数组元素个数为: ${#my_array[@]}"%

shell sed 打印输出指定行的内容

code macname@localhost Desktop % cat a.txt 1dededede 2dedefrfr 3frhvfvfvf 4frfrdede 5frfrfrfrf 6frfrede 7jukitttt 8csxssss 9zaxss 10swwww 11ssssss 12aaaaa macname@localhost Desktop % macname@localhost Desktop % macname@localhost Desktop %

shell 获取字符串的长度

  awk 方式 bogon:conf macname$ echo "abcde" | awk '{print length($0)}'5   利用${#str}来获取字符串的长度 bogon:conf macname$ a="abcdef"bogon:conf macname$ echo ${#a}6   wc 方式(注意是包含换行符的) bogon:conf macname$ echo "abcde" | wc

python 获取文件本身的绝对路径

  tester.py: import osprint (os.path.dirname(__file__))print (os.path.abspath(__file__))print (os.path.abspath(os.path.dirname(__file__)))print (os.path.dirname(os.path.abspath(__file__))) 输出 bogon:Desktop macname$ python3 tester.py /Users/macname/Desk