shell 按列切割文件
#! /usr/bin/env bash des_path=/home/zcy/temp src_path=/mnt/cnic_data/SRA_AI_DATA/tools_files/myself mouse_csv='GSM5594530_count.csv GSM5594497_count.csv' step=30000 for fname in $mouse_csv do echo $fname col_num=`awk -F ',' '{print NF; exit}' $src_path/$fname` for ((i=1; i<=$col_num; i+=$step)) do end_post=$(($i+$step-1)) new_name=${i}_${fname} if [ $i != 1 ] then cut -d ',' -f 1,$i-$end_post $src_path/$fname > $des_path/$new_name else cut -d ',' -f $i-$end_post $src_path/$fname > $des_path/$new_name fi done done
始终带上第一列