下面是我正在使用的脚本,它运行良好
# This is a test file which we are creating and this will be used to create the shell array
cat > test.txt <<End-of-message
1A|1B|1C|1D
2A|2B|2C|2D
3A|3B|3C|3D
4A|4B|4C|4D
End-of-message
set -A col1_arr `awk 'BEGIN { FS = "|" }{print $1}' test.txt`
i=0
wh
我有一个折叠的剧本:
#!/bin/sh
# this script splits a big CSV file, by 2nd column.
# the results will be as many CSV files as distinct values exist in original file, in the 2nd column.
PO_list=$(awk -F";" '{print $2}' test.csv | awk '!seen[$0]++')
for i in $PO_list;
do
c
我正在尝试创建一个脚本,以自动创建符号链接到我所有文件夹下的特定文件夹,这应该不是很难做到,但由于某些原因,我的变量在这个单线脚本中传递真的很奇怪。
#!/bin/bash
# ----------------------------------
# --------- TotalKrill -------------
# ----------------------------------
# Script to create symlinks to my clouded folder in my home directory by listing all folders/files in
我有一个shell脚本,其中有两个awk字符串。
first_awk='
BEGIN {
}
{
# create some array here..
}
END{
}
'
second_awk='
BEGIN {
}
{
## Access the array created in first awk section.
}
END{
}
'
能做上面这样的事吗?访问在后面的awk节的第一个awk节中创建的数组?
或者,我可以在包含shell脚本和访问这两个awk字符串中声明一个数组吗?
我有几个文件(*data.txt),我试图根据第1列的内容将每个文件分割成多个文件,但我不知道如何使用print将输出文件命名为$filename和第1列($1)。下面的命令中的打印给我$1 ".txt",例如: ENSG00000108094.txt,ENSG00000115232.txt,而不是file1_ENSG00000108094.txt,file1_ENSG00000115232.txt,它不适合,因为我需要为每个输入文件有单独的输出。这里是我的命令,我不知道应该在哪里使用"$b"来获得预期的结果。
for filename in *_data.tx
系统: Linux。巴什4号。
我有以下文件,它将作为变量读入脚本中:
/path/sample_A.bam A 1
/path/sample_B.bam B 1
/path/sample_C1.bam C 1
/path/sample_C2.bam C 2
我想在第一列的文件名末尾添加"_string“,但在扩展名(.bam)之前。因为在名称的开头包含路径,所以比较棘手。
期望输出:
/path/sample_A_string.bam A 1
/path/sample_B_string.bam B 1
/path/sample_C1_string.bam C 1
/path/sam
我有一些以竖线分隔的文本文件,它需要一个特定字段或一组字段的MD5散列。因为我在AIX上,并且必须使用csum函数,所以我认为不能简单地将文件和散列函数传递给awk来一举完成。
因此,我正在编写一个脚本,该脚本读取每一行,将要散列的字段传递给csum,然后通过gsub将结果作为替换项放回。99%的情况下,它看起来工作正常,但有时会出现问题,因为gsub替换了它不应该替换的东西。
#!/bin/ksh
rm $2 #Get rid of output file
while read line; do #loop through each line
MYFIELD=$(echo "$lin