Advertisement

06.27.2008 at 01:43PM PDT, ID: 23522967
[x]
Attachment Details

How can I write an alias or a script in bash that simply appends the last command to a file?

Asked by tate1615 in Bourne-Again Shell (bash), Shell Scripting

I often type out long commands that I don't want to repeat.  If I get a juicy command that works--I generally use echo to send it to a file.  Is there an alias or script that I could write in bash that could streamline this process?
Maybe a script that takes the filename as a parameter and essentially
echo !! >> filename

So that I could just do:
$ sweet_command -killer options
$ scriptname filename
And the command would shoot over to the file?Start Free Trial
 
Loading Advertisement...
 
[+][-]06.27.2008 at 01:58PM PDT, ID: 21887590

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.27.2008 at 02:05PM PDT, ID: 21887657

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.27.2008 at 02:29PM PDT, ID: 21887856

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.27.2008 at 02:37PM PDT, ID: 21887901

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.30.2008 at 02:26PM PDT, ID: 21903154

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 03:34PM PDT, ID: 21903587

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 03:47PM PDT, ID: 21903652

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Bourne-Again Shell (bash), Shell Scripting
Sign Up Now!
Solution Provided By: Tintin
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628