Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-19-2008, 03:19 AM   #1
Registered: Jun 2007
Location: India
Posts: 41

Rep: Reputation: 15
calling comman from history using variable like : !$command

suppose i store the history number of a command say :
1004 cat file

Then now i want to run it like : !1004 but by using a variable.

i am getting errors like :

can it be done ?
Thanks in advance
Old 11-19-2008, 04:20 AM   #2
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
That won't work because "!$" is the last argument of the last command line.

fc -s $command $command
should work, however.

Last edited by burschik; 11-19-2008 at 05:33 AM. Reason: mention "fc"
Old 11-20-2008, 01:55 AM   #3
Registered: Jun 2007
Location: India
Posts: 41

Original Poster
Rep: Reputation: 15
Thank you very much.

But i have also enabled shopt -s histverify
so that commands from history do not get executed but come on the current line buffer.

but in this case its getting executed right away.
if it could be paused in someway , it'l be great.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling perl script and passing variable from php script hosea Programming 5 10-21-2008 09:01 AM
how to pass a variable from a called script back to the calling script steven.c.banks Linux - General 2 05-05-2008 03:00 PM
calling a function and passing a variable the correct way Programming 2 06-07-2007 10:44 PM
calling from command line lilili Linux - Newbie 8 01-22-2006 06:09 PM
calling a variable within a variable sdandeker Programming 9 04-28-2004 04:55 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration