{"id":7367,"date":"2004-03-23T02:03:30","date_gmt":"2004-03-23T00:03:30","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/2004\/03\/23\/repeat-of-the-last-command-in-bash\/"},"modified":"2005-04-17T07:58:40","modified_gmt":"2005-04-17T04:58:40","slug":"repeat-of-the-last-command-in-bash","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2004\/03\/23\/repeat-of-the-last-command-in-bash\/","title":{"rendered":"Repeat of the last command in bash"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><img decoding=\"async\" class=\"alignright\" src=\"\/wordpress\/wp-content\/20040420-shell_small.jpg\" alt=\"\"\/>Ok, we all know that to repeat the last command in bash (as well as many other shells) you just need to press the Up key. Sometimes though it is handy to test a command before using it as a subset of a bigger command.<\/p>\n<p><!--more--><\/p>\n<p>Example: if I want to remove all sendmail RPMs from my machine, I can do so by running something like:<\/p>\n<pre>[leonid@home tmp]# rpm -e `rpm -qa | grep sendmail`<\/pre>\n<p>While I am sure this command works, I am not completely aware of which exactly RPMs it will remove. So, before I run it, I want to test:<\/p>\n<pre>[leonid@home tmp]# rpm -qa | grep sendmail\r\nsendmail-cf-x.y.z\r\nsendmail-x.y.z<\/pre>\n<p>Ok, now I am sure and I want to remove all those. One way would be to actually hit the Up arrow, put the backtick quotes around the whole thing, then add &#8220;rpm -e&#8221; in the beginning and we are done. All that movement is annoying to some (me, for instance). So, here is what I do instead:<\/p>\n<pre>[leonid@home tmp]# rpm -e `!!`<\/pre>\n<p>Yes, you are right, those are two exclamation marks. Easy, huh? :) Aparently, exclamation mark usage can do more good then jus that. For example &#8220;!se&#8221; will run the last command beginning with &#8220;se&#8221; in your history file. I&#8217;ve got used so much to this feature now that I cannot even imagine myself without it anymore. :)<\/p>\n<p><b>P.S.:<\/b> For purist and RPM fanatics: yes, I could have used the simple &#8220;<code>rpm -e --test `rpm -qa | grep sendmail`<\/code>&#8221; thingy, but I needed the example, so&#8230; :)<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Ok, we all know that to repeat the last command in bash (as well as many other shells) you just need to press the Up key. Sometimes though it is handy to test a command before using it as a subset of a bigger command.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[1960],"keyring_services":[],"class_list":["post-7367","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-command-line"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":118,"url":"https:\/\/mamchenkov.net\/wordpress\/2003\/01\/14\/practical-rpm\/","url_meta":{"origin":7367,"position":0},"title":"Practical RPM","author":"Leonid Mamchenkov","date":"January 14, 2003","format":false,"excerpt":"This document presents few practical tips for users of Redhat Pacakage Manager (RPM). Introduction This document will not cover or explain any theory behind RPM, since it has been nicely done in few other documents. Please consider reading man rpm for a general list of options and RPM-Howto for the\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18615,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/09\/18\/fedora-dropping-default-sendmail-and-rsyslog-insta\/","url_meta":{"origin":7367,"position":1},"title":"Fedora dropping default Sendmail and rsyslog insta&#8230;","author":"Leonid Mamchenkov","date":"September 18, 2013","format":"status","excerpt":"Fedora dropping default Sendmail and rsyslog install for the 20th release. \u00a0Reading through the reasoning makes all the sense. \u00a0But I'm still emotional.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7388,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/03\/23\/how-can-i-see-a-list-of-all-installed-rpms-on-my-system\/","url_meta":{"origin":7367,"position":2},"title":"How can I see a list of all installed RPMs on my system?","author":"Leonid Mamchenkov","date":"March 23, 2004","format":false,"excerpt":"\"rpm listing installed rpms\" \"list all installed rpms\" \"list installed packages rpm\" Viewing a list of all installed RPMs on a system is as simple as typing in rpm -qa . Most probably, you'll want to see the resulting list alphabetically sorted. You can do that by typing rpm -qa\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":42578,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/05\/02\/fedora-30\/","url_meta":{"origin":7367,"position":3},"title":"Fedora 30","author":"Leonid Mamchenkov","date":"May 2, 2019","format":false,"excerpt":"Fedora 30 has been released a few days ago. In the long list of changes, the most interesting to me are: Upgrade to Bash 5Upgrade to PHP 7.3 (more specifically 7.3.4)Deprecation of \/etc\/sysconfig\/nfs in favor of \/etc\/nfs.conf I've already upgraded my laptop to this version and everything seems to work\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/05\/fedora30.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/05\/fedora30.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/05\/fedora30.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/05\/fedora30.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":17835,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/03\/08\/redmine-email-notifications-with-exim\/","url_meta":{"origin":7367,"position":4},"title":"Redmine email notifications with Exim","author":"Leonid Mamchenkov","date":"March 8, 2013","format":false,"excerpt":"When configuring Redmine project management to send email notifications, using Exim MTA, you might end up with test emails bouncing due to no\u00a0recipients\u00a0specified. \u00a0It's a bit tricky to debug, but, fortunately, quite easy to fix. \u00a0The problem comes from different implementations of \"-t\" option handling for \/usr\/sbin\/sendmail. \u00a0Redmine uses this\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7380,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/03\/23\/how-can-i-display-a-list-of-all-rpm-packages-on-the-system-with-their-sizes\/","url_meta":{"origin":7367,"position":5},"title":"How can I display a list of all rpm packages on the system with their sizes?","author":"Leonid Mamchenkov","date":"March 23, 2004","format":false,"excerpt":"\"rpm query size\" RPM (Red Hat Package Manager) has an excellent --qf (query format) option, which behaves much like printf function. Command rpm -q mozilla --qf '%{SIZE} \\n' will display the size of mozilla package. To list all packages with their sizes, you may use something like: rpm -qa --qf\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/7367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=7367"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/7367\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=7367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=7367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=7367"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=7367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}