cygwin中的文件名操作 [英] Filename manipulation in cygwin
问题描述
我在 Windows 7上运行 cygwin 。我使用信号处理工具,基本上执行对齐。我有大约1200个输入文件。每个文件的格式如下。
input_file_ format =AC_XXXXXX.abc
所有输入文件的某种索引,这是用工具的 build-index
命令完成的,现在每个文件有6个索引与它相关联。因此现在我有大约1200 * 6 = 7200个索引文件。索引具有以下给出的形式。
indexes_format =AC_XXXXXX.abc.1,
AC_XXXXXX.abc.2,
AC_XXXXXX.abc.3,
AC_XXXXXX.abc.4,
AC_XXXXXX.abc.rev.1,
AC_XXXXXX。 abc.rev.1
现在,我需要使用这些索引来执行对齐。每个文件的所有6个索引被一起调用,最终操作如下。
信号处理工具-to-indexes \AC_XXXXXX.abc .. \Query file
其中 AC_XXXXXX.abc 索引与该特定索引文件相关联。所有6个索引文件用** AC_XXXXXX.abc *调用。
我的问题是,我只需要使用索引文件名的前14个字符进行最终操作。
当我使用下面的代码,不会执行对齐。
用于索引中的文件/ *; do ./tool $ file | cut -b1-14 Project / query_file;
首先,请记住,$ file将始终以indexes /开头,因此修剪前14个字符将始终包含该文件夹名称。
要使用变量中的前14个字符,请使用 $ {file:0:14}
,其中0是起始字符串索引,14是长度
或者,如果你想使用cut,你需要在subshell中运行它:用于索引中的文件/ * ; do ./tool $(echo $ file | cut -c 1-14)Project / query_file; done
我将 cut
的arg更改为-c,而不是字节
I am running cygwin on Windows 7. I am using a signal processing tool and basically performing alignments. I had about 1200 input files. Each file is of the format given below.
input_file_ format = "AC_XXXXXX.abc"
The first step required building some kind of indexes for all the input files, this was done with the tool's build-index
command and now each file had 6 indexes associated with it. Therefore now I have about 1200*6 = 7200 index files. The indexes are of the form given below.
indexes_format = "AC_XXXXXX.abc.1",
"AC_XXXXXX.abc.2",
"AC_XXXXXX.abc.3",
"AC_XXXXXX.abc.4",
"AC_XXXXXX.abc.rev.1",
"AC_XXXXXX.abc.rev.1"
Now, I need to use these indexes to perform the alignment. All the 6 indexes of each file are called together and the final operation is done as follows.
signal-processing-tool ..\path-to-indexes\AC_XXXXXX.abc ..\Query file
Where AC_XXXXXX.abc is the index associated with that particular index file. All 6 index files are called with **AC_XXXXXX.abc*.
My problem is that I need to use only the first 14 characters of the index file names for the final operation.
When I use the code below, the alignment is not executed.
for file in indexes/*; do ./tool $file|cut -b1-14 Project/query_file; done
I'd appreciate help with this!
First of all, keep in mind that $file will always start with "indexes/", so trimming first 14 characters would always include that folder name in the beginning.
To use first 14 characters in a variable, use ${file:0:14}
, where 0 is the starting string index, and 14 is the length of the desired substring.
Alternatively, if you want to use cut, you need to run it in a subshell: for file in indexes/*; do ./tool $(echo $file|cut -c 1-14) Project/query_file; done
I changed the arg for cut
to -c for characters instead of bytes
这篇关于cygwin中的文件名操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!