Join the community today
Become a Member

Delete history commands from line 125 up to 285

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

  1. pamamolf

    pamamolf Premium Member Premium Member

    4,068
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    5:14 AM
    Nginx-1.25.x
    MariaDB 10.3.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

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    12:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,068
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    5:14 AM
    Nginx-1.25.x
    MariaDB 10.3.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

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    12:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah you just run the one liner command in SSH