TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Unix Learnings > Remove a command from History

Sourav Gulati
Site Owner
Posts: 83

You can remove a command from history as follows:

$history -d <offset>

For example,

$ history

1 cd /home

2 rm filename

3 ls -l

4 touch new

5 cp new new1

6 history


$ history -d 4


$ history

1 cd /home

2 rm filename

3 ls -l

4 cp new new1

5 history

6 history -d 4

7 history




--


December 20, 2012 at 1:26 AM Flag Quote & Reply

Sourav Gulati
Site Owner
Posts: 83

Also , if you want to execute a command from history it can be executed as 

$ !<offset>

for example,

$ !3

will execute "ls -l"

--


December 20, 2012 at 3:58 AM Flag Quote & Reply

You must login to post.