I need to change a single line in a file. It is always in the first line of the file.
It looks like:
h n0 n1 n2 n3 n4 n5 n6 n7 n8 n9 hilu cjt 1 1000000
there is a tab in all gaps except after the h.
I would need to re-transform the line into
h n1 n2 n3 n4 n5 n6 n7 n8 n9
hilu cjt 1 1000000
at the beginning o the line the thing and n0 needs to go and there needs to be a tab between h and n1. Then a newline needs to start before hilu but there should be no additional tab after n9
Ideally I would just feed my file to the script and it would not require writing an intermediate script to fill.
is there maybe an efficient version in Perl or python or so? I thought about R but then there are 1000 of lines in the file and only the first lien needs be changed...
tried to use the solution from jahid to run it from r with
> system(paste("sed -r '1s/(.*) (REGION.*)/1
2/;1s/\t[^[:space:]]+//'","arg_t1"))
sed: -e expression #1, char 20: unterminated `s' command
with the suggest from the comm I get
> system(paste("sed -r "1s/(.*) (REGION.*)/1
2/;1s/\t[^[:space:]]+//"","arg_t1"))
sed: -e expression #1, char 20: unterminated `s' command
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…