Re-Use A Bash Command With Different Parameters

Suppose you have typed and executed this command in your Linux shell:

1
./script_a.sh 1.23 && ./script_b.sh 1.23 && ./script_c.sh 1.23.45

Now you want to run the same command, but with 2.34 instead of 1.23
A nice way to do it is this:

1
!!:gs/1.23/2.34

Meaning, run the last command (!! is also called ‘bang bang’, and it’s substituted by the last command you executed), and replace every instance of 1.23 by 2.34

via Unix Bash Scripting.
Have fun ;)

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Related posts:

  1. Strip the File Name Suffix off a Bash Variable
  2. Fetch Links From Twitter Into Your RSS Reader
  3. Strip Leading Characters Off A String
  4. Trimming Bash Variables – A Summary
  5. Bash Tip – Separate a Bash Variable From Surrounding Letters

Tags: ,

Sunday, September 27th, 2009 Bash

Leave a Reply

my email
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
I'm a Verification Engineer in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
September 2009
S M T W T F S
« Jul   Dec »
 12345
6789101112
13141516171819
20212223242526
27282930  
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.