我想以简单的方式复制和粘贴任务。我有一个超过3000行的文件。我怎么能在linux上做?
文本文件
#: Bib Field 111
where liblibrarian = "MAIN ENTRY--MEETING NAME";
update marc_subfield_structure set liblibrarian = "TEMEL GİRİŞ--TOPLANTI ADI", libopac =
#: Bib Sub 111 f
where liblibrarian = "Date of a work";
update marc_subfield_structure set liblibrarian = "Eserin tarihi", libopac =
#: Bib Sub 111 k
where liblibrarian = "Form subheading";
update marc_subfield_structure set liblibrarian = "Alt başlık biçimlendir", libopac =
#: Bib Sub 111 l
where liblibrarian = "Language of a work";
update marc_subfield_structure set liblibrarian = "Eserin dili", libopac =
#: Bib Sub 111 n
where liblibrarian = "Number of part/section/meeting";
update marc_subfield_structure set liblibrarian = "Parça/bölüm/toplantı sayısı", libopac =
我想要
update marc_subfield_structure set liblibrarian = "Toplantı yeri", libopac = "Toplantı yeri" where liblibrarian = "Location of meeting";
update marc_subfield_structure set liblibrarian = "Relator kodu", libopac = "Relator kodu" where liblibrarian = "Relator code";
update marc_subfield_structure set liblibrarian = "Eserin adı", libopac = "Eserin adı" where liblibrarian = "Title of a work";
update marc_subfield_structure set liblibrarian = "Relator terim", libopac = "Relator terim" where liblibrarian = "Relator term";
答案 0 :(得分:1)
也许您可以使用awk或sed等其他工具轻松完成。但我认为也可以通过以下方式完成:
通过以下命令创建一个仅包含'where liblibrarian ..'部分的文件:
grep 'where liblibrarian' <file> > first_file
创建一个仅包含'update marc_subfield_structure ..'的文件:
grep 'update marc_subfield_structure' <file> > second_file
现在你有两个文件,其中每一行包含你想要构建的最终部分。因此,您只需使用以下命令逐列粘贴它们(您可以根据需要调整分隔符)。
paste second_file first_file | column -s $'\t' -t
因此,最后一个命令将通过在它们之间插入分隔符来粘贴这些行。