Wednesday, October 17, 2012

Listing history commands using 'fc'

In Linux, the command 'fc' (stands for find command) can be used as an alternative to 'history'. 
This is a Bash built-in command using which we can list only the selected number of last executed commands.

For example, if you wish to list only last 20 commands, the syntax for 'fc' command should be "fc -l -20".
Below shown is a sample execution:

linuxhost # fc -l -20
1081     ls
1082     cd current/
1083     ls
1084     make
1085     make linux
1086     make target
1087     history | grep iozone
1088     iozone -a -i 0 -i 1 -i 2 -r 32k
1089     df -h
1090     ps -fu gpadmin | grep iozone
1091     man iozone
1092     exit
1093     df -h
1094     df -h
1095     cd /gplum/
1096     du -sh .
1097     top
1098     uname -r
1099     free -m
1100     getconf -a | grep -i pagesize
linuxhost #

No comments:

Post a Comment