删除文件名的中间 [英] Removing Middle of Filename

查看:54
本文介绍了删除文件名的中间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望删除如下所示的中间文件名:

I wish to remove the middle of filenames that look like the following:

Wm-no-Bis.GAGATTCC-ATAGAGGC.L001.R1.001.fastq.trim.R2.fastq
Pek-no-Bis.GAGATTCC-AGGCGAAG.L001.R1.001.fastq.trim.R1.fastq

获取

Wm-no-Bis.trim.R2.fastq
Pek-no-Bis.trim.R1.fastq

如您所见,文件的开头和结尾略有不同.我尝试使用重命名如下:

As you can see the beginning and end of the files are slightly variable. I have attempted to use rename as follows:

rename 's/.*.*.*.*.*.trim.//g'
Wm-no-Bis.GAGATTCC-ATAGAGGC.L001.R1.001.fastq.trim.R2copy.fastq

这会删除整个文件名,但结尾除外.问题显然是我对如何使用通配符缺乏了解.

This removes the entire file name except for the end. The issue is obviously my lack of understanding how to use wildcards.

推荐答案

您可以使用这个 rename 命令:

You can use this rename command:

rename -n 's/^([^.]+).*(\.trim\..*)$/$1$2/' *.fastq

当您对输出感到满意时,请删除 -n 选项(试运行)

When you're happy with output then remove -n option (dry-run)

这篇关于删除文件名的中间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆