随笔分类 -  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 阅读(739) 评论(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 阅读(53) 评论(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 阅读(49) 评论(0) 推荐(0) 编辑

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

posted @ 2022-01-21 10:01 BioinformaticsMaster 阅读(37) 评论(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 阅读(98) 评论(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 阅读(243) 评论(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 阅读(949) 评论(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 阅读(53) 评论(0) 推荐(0) 编辑

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

posted @ 2022-01-01 11:28 BioinformaticsMaster 阅读(87) 评论(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 阅读(294) 评论(0) 推荐(0) 编辑

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

posted @ 2021-12-22 15:57 BioinformaticsMaster 阅读(1972) 评论(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 阅读(237) 评论(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 阅读(169) 评论(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 阅读(926) 评论(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 阅读(1278) 评论(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 阅读(961) 评论(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 阅读(338) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示