随笔分类 -  Shell

Linux Shell
shell 判断条件,退出程序
摘要:$cat exit.sh testvcf=$1 if [ ! -f $testvcf ];then echo "testvcf nonexist :$testvcf" exit 0 fi echo "run successful" $ cat run_Exit.sh sh exit.sh 3err 阅读全文

posted @ 2022-03-17 14:46 BioinformaticsMaster 阅读(749) 评论(0) 推荐(0)

rsync 本地路径到挂盘路径 ;挂盘路径到本地
摘要:要解决的是每次都要输入密码,所以不能后台投递任务。 解决方案: 核心是expect spawn #!/usr/bin/expect -f set timeout 10 set username [lindex $argv 0] set password [lindex $argv 1] set ho 阅读全文

posted @ 2022-01-25 15:18 BioinformaticsMaster 阅读(61) 评论(0) 推荐(0)

linux 帐号便捷登陆
摘要:核心 如设置便捷su #!/usr/bin/expect -f set port port_no set user st_mchri_bigdata set password Genomics20210 set timeout -1 spawn su $user expect "*assword:* 阅读全文

posted @ 2022-01-21 17:35 BioinformaticsMaster 阅读(56) 评论(0) 推荐(0)

集群.bashrc不涉及路径
摘要:集群个人目录下的.bashrc不要涉及source/export路径,不然有些盘故障,就会影响任何形式的访问。 1. 登陆卡住 2.scp 卡住 解决方法: 涉及路径的自定义环境变量可以写在如 ~/profile.sh这样的脚本里边,在使用时在shell里边source ~/profile.sh使环 阅读全文

posted @ 2022-01-21 10:01 BioinformaticsMaster 阅读(41) 评论(0) 推荐(0)

给指定用户开通读写权限
摘要:setfacl -m u:st_mchri_bigdata:rxw -R /jdfssz1/ST_HEALTH/P21Z10200N0047/lizhichao/data_transfer setfacl -m u:st_rm:rx -R /zfssz3/ST_MCHRI/BIGDATA/autoa 阅读全文

posted @ 2022-01-13 10:13 BioinformaticsMaster 阅读(110) 评论(0) 推荐(0)

tar 压缩文件list所有文件
摘要:行尾$替换为 \ 注:空格\ 第一行行首加tar czvf 压缩后文件前缀.tar.gz 最后一行行尾可以加 && echo "done" 结果如下: tar czvf test.tar.gz COVIDHarbin.list.csv \COVIDHarbin.list.csv_copy \COVI 阅读全文

posted @ 2022-01-12 21:23 BioinformaticsMaster 阅读(254) 评论(0) 推荐(0)

sort 命令对文件多列详细排序
摘要:sort 命令 默认是打印出来,可以通过定向符> 或-o 指定输出文件 -t ' ' 指定分隔符为空格 -k 指定按分隔后的第几域排序 -n 按数值大小排序,默认是升序(从小到大) -r 表示逆序 reverse sort -t ' ' -k 1 sort_test.file # 对第一域默认按AS 阅读全文

posted @ 2022-01-12 21:10 BioinformaticsMaster 阅读(1020) 评论(0) 推荐(0)

linux按行取文件
摘要:文件前几行 head -n 5 $file 文件后几行 tail -n -5 $file 文件从第几行到结尾 tail -n +5 $file 区间行的文件 sed -n '2,5p' $file # 第二行到第5行 阅读全文

posted @ 2022-01-12 17:42 BioinformaticsMaster 阅读(62) 评论(0) 推荐(0)

shell 判断目录是否存在
摘要:if [ ! -d "./shell" ];then mkdir ./shell fi # 注意[]内的各个空格 阅读全文

posted @ 2022-01-01 11:28 BioinformaticsMaster 阅读(91) 评论(0) 推荐(0)

awk场景命令
摘要:# 注 mac 要用gwak代替awk. ~/Documents/materials/linux_shell  awk 'BEGIN{FS=OFS="\t"} NR==FNR{a[$3]=$1;b[$3]=$2} NR>FNR{$2=a[$1];$3=b[$1]; {print $2,$3,$1} 阅读全文

posted @ 2021-12-31 19:57 BioinformaticsMaster 阅读(343) 评论(0) 推荐(0)

MAC iterm2 ssh显示不全 解决
摘要:BUG : 解决方法: 在profile 勾选unlimited scrollback 阅读全文

posted @ 2021-12-22 15:57 BioinformaticsMaster 阅读(2106) 评论(0) 推荐(0)

find . -type f -exec ls -l {} \;
摘要:find 命令 查找,搭配exec 对查找到的文件操作。 -exec 后跟command,终止以;结尾,考虑到分号在不同系统中的不同含义,所以习惯用\;转译。 花括号{}指代前面find查找到文件。 例子: find . -type f -exec ls -l {} \; find -type f 阅读全文

posted @ 2021-11-09 10:41 BioinformaticsMaster 阅读(284) 评论(0) 推荐(0)

shell 替换,匹配
摘要:>替换shell字符串: echo ${string/23/bb} //abc1bb42341 替换一次 echo ${string//23/bb} //abc1bb4bb41 双斜杠替换所有匹配 echo ${string/#abc/bb} //bb12342341 #以什么开头来匹配,根php中 阅读全文

posted @ 2020-09-20 15:11 BioinformaticsMaster 阅读(175) 评论(0) 推荐(0)

Sambamba 安装 ,软件加入PATH使各级路径都可运行,所谓环境变量
摘要:最简单的方式是下载编译后的软件:*.static.gz 1.如: wget https://github.com/biod/sambamba/releases/download/v0.7.1/sambamba-0.7.1-linux-static.gz2.gunzip sambamba-0.7.1- 阅读全文

posted @ 2020-09-15 02:48 BioinformaticsMaster 阅读(978) 评论(0) 推荐(0)

shell 判断字符串/文件是否存在
摘要:str="this is a string" [[ $str =~ "this" ]] && echo "$str contains this" 判断文件: if [ -f $fq1 ]then fq2=`ls /home/input${RGID}/*_2.fq.gz`else fq1=`ls /h 阅读全文

posted @ 2020-09-09 04:15 BioinformaticsMaster 阅读(1295) 评论(0) 推荐(0)

sed 取行,删行,新增行,替换字符串 ;grep 取匹配行
摘要:nl /etc/passwd |sed '2,5 d' 删除文件2-5行nl命令 输出的文件内容自动加上行号 sed [-nefr] [动作] 以行为单位 注意: 在-i 时,mac 与linux稍有不同,需要加空格,如 sed -i '' '/CMDCB0003112/d' 467gvcf.lis 阅读全文

posted @ 2020-09-09 04:12 BioinformaticsMaster 阅读(1084) 评论(0) 推荐(0)

less 文件少一行, python -join -write ,shell 逐行读取
摘要:用python file.write("\n".join(line_list)) 方式将多行内容组成的列表写入文件。文件末行没有换行符, 因此vi打开文件会因为如同window系统一般的文件结尾,提示:[noeol] 且,less |wc-l 的方式数行数会比实际行数少一行。 这样的输出文件用pyt 阅读全文

posted @ 2020-03-03 12:14 BioinformaticsMaster 阅读(350) 评论(0) 推荐(0)

convert 安装 转换文件格式报错的解决方案
摘要:1. convert安装: 2. 遇到的问题: 3.该问题解决办法: 网上有这样的,亲测:不管用。pass contributed:对于没有运行Web服务器的桌面用户,只需消除这些限制就足够了。为此目的,可以删除文件,或重命名该文件。因此,所有政策都取消了,但如果需要,您仍可以恢复. 因为我的工具就 阅读全文

posted @ 2019-07-04 15:21 BioinformaticsMaster 阅读(2658) 评论(0) 推荐(0)

shell case 判断
摘要:注 :1、*) 相当于其他语言中的default。 2、除了*)模式,各个分支中;;是必须的,;;相当于其他语言中的break 3、 | 分割多个模式,相当于or 参考:https://blog.csdn.net/love__coder/article/details/7262160 阅读全文

posted @ 2018-05-28 21:14 BioinformaticsMaster 阅读(174) 评论(0) 推荐(0)

Git 简介和下载安装
摘要:Git 简介: Git 是处理文本文件的版本管理系统。 Github获取Git的提交历史,并保存在互联网,以供远程(联网)访问。 工作过程: 1)创建本地分支,在本地分支编辑,修改,提交。 2)push到远程分支 3)申请merge到主分支,发布请求 Pull Request 4)审核merge 5 阅读全文

posted @ 2018-02-02 17:08 BioinformaticsMaster 阅读(189) 评论(0) 推荐(0)

导航