你可以用 sed 's|$|.tsv|' myfile.txt
sed 's|$|.tsv|' myfile.txt
我要编辑的列如下所示:
$ cut -f12 chickspress.tsv | sort -u | head Adipose_proteins Adrenal_gland Cerebellum Cerebrum Heart Hypothalamus Ovary Sciatic_nerve Testis Tissue
sed 结果是错误的:
sed
$ cut -f12 chickspress.tsv | sort -u | sed -e 's|$|.tsv|' .tsvose_proteins .tsvnal_gland .tsvbellum .tsvbrum .tsvt .tsvthalamus .tsvy .tsvtic_nerve .tsvis .tsvue .tsvey .tsvr .tsv .tsvreas .tsvoral_muscle .tsventriculus
.tsv
我想可能有一些空白错误,所以我尝试了这个(macos):
$ cut -f12 chickspress.tsv | sort -u | cat -ve Adipose_proteins^M$ Adrenal_gland^M$ Cerebellum^M$ Cerebrum^M$ Heart^M$ Hypothalamus^M$ Ovary^M$ Sciatic_nerve^M$ Testis^M$ Tissue^M$ kidney^M$ liver^M$ lung^M$ pancreas^M$ pectoral_muscle^M$ proventriculus^M$
^M
csv.DictWriter
awk '{sub(/\r$/,"")} 1' Input_file > temp_file && mv temp_file Input_file
sed -i.bak '#s#\r$##' Input_file
通过执行以下操作删除控件m字符,然后尝试您的命令。
tr -d '\r' < Input_file > temp_file && mv temp_file Input_file
dos2unix 实用程序在您的系统中也可以使用它来删除这些字符。
dos2unix
awk 以下内容:
awk
awk '{gsub(/\r/,"")} 1' Input_file > temp_file && mv temp_file Input_file
sed -i.bak 's#\r##g' Input_file