[英]How to replace extension in bash regex?
I'm trying to write a bash script to calculate some biological stuff. 我正在尝试编写一个bash脚本来计算一些生物学东西。 I have a problem with regex, bash is a little unfamiliar to me yet.
我有正则表达式的问题,bash对我来说有点不熟悉。 Unfortenly I have no time to learn it that fast coz I need immanently results.
不幸的是,我没有时间去学习快速因为我需要内在的结果。 So my files:
所以我的文件:
RV30.afa
resFilesRV30.fasta
RV30213.afa
resFilesRV30213.fasta
RV30441.afa
resFilesRV30441.fasta
...
Command i have to use: 命令我必须使用:
mscore -cftit RV30.afa resFilesRV30.fasta >FinalRV30.txt'
What i have now: 我现在拥有的:
#!/bin/bash
parallel 'mscore -cftit {} resFile{}.fasta >final{.}.txt' ::: RV*.afa
The problem is: resFile{}.fasta = is trying to open file like this: resFileXXX. 问题是:resFile {}。fasta =正在尝试打开这样的文件:resFileXXX。 afa .fasta i need to skip extension in second argument (.afa) and ovewritte it by ".fasta".
afa .fasta我需要在第二个参数(.afa)中跳过扩展名并用“.fasta”覆盖它。
I didn't find a piece of good advice on google for my problem (or i can't reforge it to my script yet), and my time to get results already ends. 我没有在google上找到一条关于我的问题的好建议(或者我还不能将它重新编写到我的脚本中),而且我获得结果的时间已经结束了。 So i will be grateful for help in solving this problem.
所以我将非常感谢帮助解决这个问题。 On its basis, I will be able to solve some of the others that appeared in my other scripts
在此基础上,我将能够解决其他脚本中出现的其他一些问题
This should work for you by substituting {}
with {.}
in 2nd argument: 这应该替换为你工作
{}
与{.}
在第二个参数:
parallel 'mscore -cftit {} resFiles{.}.fasta >final{.}.txt' ::: RV*.afa
As you're using already in your command, the replacement string {.}
removes the extension. 正如您在命令中使用的那样,替换字符串
{.}
将删除扩展名。
这不起作用吗?
for afafile in *.afa; do number="${afafile#file}"; number="${number%.afa}"; ./mscore -cftit "$afafile" "resFile${number}.fasta" > "file${number}final.txt"; done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.