Let's say you have executed the following command (bit long) some time ago:
"bash /root/itc/hc/dyn/nmon -f -t -m /var/log/nmon -s300 -r iss-365-rhel5664-tmpl.xyz.com -c196"
Now you wish to execute the same command with one value changed in it. Instead of -s300, you want to re-run the command with the new value -s200.
hostxyz # fc -l <-- Will list 16 most recent commands
428 ls -l
429 vim NMON_startup_script.sh-May-16-12.log
430 sh /root/itc/hc/dyn/NMON_startup_script.sh
431 cat NMON_startup_script.sh-May-16-12.log
433 perl /opt/sysinfo.pl
434 ls -l /var/lock/subsys
435 bash /root/itc/hc/dyn/nmon -f -t -m /var/log/nmon -s300 -r iss-365-rhel5664-tmpl.xyz.com -c196
436 cd ~ashok
438 ps -ef | grep nmon
439 kill -15 3384
441 fc -l
442 ps -ef | grep nmon
hostxyz # fc -s s300=s200 bash
bash /root/itc/hc/dyn/nmon -f -t -m /var/log/nmon -s200 -r iss-365-rhel5664-tmpl.xyz.com -c150
With the `fc -s [pat=rep ...] [command]' format, the command starting with 'bash' is re-executed after the substitution OLD=NEW is performed.
Note: Typing just 'fc' will open the last command in Text Editor. If you want to open range of commands that you executed before in Text Editor, you can use the following syntax: # fc [Start no] [End no].