Join the community today
Register Now

Delete history commands from line 125 up to 285

Discussion in 'System Administration' started by pamamolf, Aug 26, 2014.

  1. pamamolf

    pamamolf Well-Known Member

    2,726
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    12:42 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hi

    How can i delete from ssh history commands the lines from 125 up to 285?

    I don't want to add as parameter each number like 125 126 127 and so on .....

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,196
    6,789
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,144
    Local Time:
    7:42 PM
    Nginx 1.13.x
    MariaDB 5.5
    bit of shell scripting using a for sequence loop should do it

    Code:
    for i in $(seq 125 285); do history -d $i; done
    
    so end up doing

    history -d 125
    history -d 126

    all the way till

    history -d 285
     
    • Like Like x 1
  3. pamamolf

    pamamolf Well-Known Member

    2,726
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    12:42 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Can i just run this command from ssh or i must create a file .sh and add it inside and then run this file?

    Thanks
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,196
    6,789
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,144
    Local Time:
    7:42 PM
    Nginx 1.13.x
    MariaDB 5.5
    yeah you just run the one liner command in SSH
     
    • Like Like x 1