2021年3月10日

Shell 脚本 Tips

摘要: 数组 filepath="everything mobaxterm gems" arr=($filepath) 打印某个元素 judgefile=${arr[0]} 打印全部元素 echo ${arr[@]} 循环打印每个元素 for x in ${arr[@]}; do echo $x done 阅读全文

posted @ 2021-03-10 18:51 liujx2019 阅读(39) 评论(0) 推荐(0) 编辑

Bash 脚本 逐行处理文本文件的内容

摘要: while read -r line; do echo "$line" done < /path/to/file.txt https://unix.stackexchange.com/questions/58040/what-is-the-fastest-way-to-process-line-by 阅读全文

posted @ 2021-03-10 14:31 liujx2019 阅读(192) 评论(0) 推荐(0) 编辑

Bash 脚本 从路径分离出文件夹和文件名

摘要: bash to get file name fspec="/exp/home1/abc.txt" filename="${fspec##*/}" # get filename dirname="${fspec%/*}" # get directory/path name other ways awk 阅读全文

posted @ 2021-03-10 14:25 liujx2019 阅读(286) 评论(0) 推荐(0) 编辑

Linux 跨平台编译调试

摘要: 把修改过的代码发送到编译的机器 #!/bin/bash if [ $# -lt 1 ] then echo "Input the destination such as root@10.4.10.78:~/src/" exit fi file_list="file_list" update_scri 阅读全文

posted @ 2021-03-10 13:56 liujx2019 阅读(95) 评论(0) 推荐(0) 编辑

tr与sed命令:将换行符替换为空格

摘要: 处理文本时需要将换行符替换为空格,若使用sed命令会比较麻烦,而使用tr命令非常方便。 cat country.txt | sed ':label;N;s/\n/ /;b label' cat country.txt | tr "\n" " " 两个命令输出一致,但是sed命令的输出结尾有换行符,而 阅读全文

posted @ 2021-03-10 13:37 liujx2019 阅读(2258) 评论(0) 推荐(0) 编辑

导航