Search code examples
sedgnuplotaix

AIX : sed command to delete pattern for all the lines except the first


With AIX 7.X, I've those lines for my gnuplot script :

set terminal png truecolor size 1950, 650  background rgb "#eff1f0" 
set output "/xxx/xxxx/xxx/xxx/xxx.png"
set datafile separator ';'

set size ratio 0.2
set bmargin at screen 0.2
unset key
set datafile separator ";"
set ylabel " MB BLOCK " font ",10" offset -1,0
set xlabel font ",10"
set xtics rotate by 45  offset -0.8,-9,-1.8


plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5

I want to delete the pattern " plot " for all the lines, except the first... With my linux I do this :

sed '0,/plot/! s/plot//g' myfile.txt

And the result is :

set terminal png truecolor size 1950, 650  background rgb "#eff1f0" 
set output "/var/IBMtools/www/tim/used.png"
set datafile separator ';'

set size ratio 0.2
set bmargin at screen 0.2
unset key
set datafile separator ";"
set ylabel " MB BLOCK " font ",10" offset -1,0
set xlabel font ",10"
set xtics rotate by 45  offset -0.8,-9,-1.8


plot "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5, \ 
 "xx/xx/file.txt" using 3:xtic(1) title column(2) with linespoints linewidth 2 pointtype 7 pointsize 1.5

But this command doesn't works with AIX. The error is sed: 0602-403 0,/plot/! s/plot//g is not a recognized function.

Please, could you show me how to do that ?


Solution

  • If plot is not in the first line in the file, you could do this:

    sed '1,/plot/!s/plot//'
    

    If it can be on the first line, I see no other way but to loop it:

    sed ':a;/plot/!{n;ba;};:b;n;s///;bb'