N個字符插入一個常量字符串到一個文本文件中的每一行,我需要爲了一個bash或AWK或sed的解決方案插入一個文件的每一行的字符串,在N空間後如何在bash
例如,我想這個文件
Nov 30 23:09:39.029313 sad asdadfahfgh
Nov 30 23:09:39.029338 ads dsfgdsfgdf
Nov 30 23:09:46.246912 hfg sdasdsa
Nov 30 23:09:46.246951 jghjgh dfgdfgdf
是
Nov 30 23:09:39.029313 my_constant_string sad asdadfahfgh
Nov 30 23:09:39.029338 my_constant_string ads dsfgdsfgdf
Nov 30 23:09:46.246912 my_constant_string hfg sdasdsa
Nov 30 23:09:46.246951 my_constant_string jghjgh dfgdfgdf
我嘗試以下但不工作:
awk '{print $2" "$3" "$4" crit { for(i=5;i<NF;i++) print $i}}' log_file
發表您嘗試 –
我想貓LOG_FILE | awk'{print $ 2''$ 3''$ 4'crit {for(i = 5; i
sotiris