user3076248
user3076248

Reputation: 15

Shell history command- function

Hi I'm trying to implement a shell on linux and I'm suppose to line up the last 10 commands in the shell's history.

I'm using system("cat ~/.bash_history"); command but I dont know how to bring up just last 10 commands.

Thanks in advance

Upvotes: 0

Views: 285

Answers (1)

user2486495
user2486495

Reputation: 1729

Try tail command and -n is number of last lines,

system("tail -n 10 ~/.bash_history");

Upvotes: 1

Related Questions