Wednesday, February 21, 2007

Ctrl+R ค้นหาคำสั่งใน History

เวลาใช้ command ใน shell แล้วอยากดูว่าเราเคยใช้ command ใดไปบ้าง สามารถเรียกดูด้วยคำสั่ง #history ซึ่งมันก็จะแสดงลำดับที่ และ command ที่เคยใช้ มากน้อยแล้วแต่การใช้งาน ที่นี่ในกรณีที่มันมากเกินไป หรือกรณีที่แบบจำรูปแบบคำสั่งไม่ได้ จำได้เป็นบางคำ เราสามารถค้นหาคำสั่งนั้นได้ด้วยการกด ctrl+R แล้วคีย์คำค้นลงไป มันก็จะแสดงให้แล้วเราก็รันคำสั่งนั้นได้ด้วยการกด Enter เท่านี้ก็เป็นก็รวดเร็ว ประหยัดเวลา และไม่ต้องไปจำรูปแบบคำสั่งแบบเต็ม ๆ กันอีกแล้ว

Search in bash history

If you’d like to search in bash history for a command you typed earlier, press ctrl + R then type the string you are looking for, press ctrl + R again to browse the history containing your query.

Press ctrl + O or enter to execute the command

Reference:

1. http://www.wains.be/index.php/category/linux/13/page/3/

2. http://www.ubuntuclub.com/html/index.php?option=com_joomlaboard&Itemid=38&func=view&catid=2&id=3455#3455

No comments: