Latest Computer Forum Topics:

  • Nintendo "Hand-Held" ? (8 posts)
  • my laptop has no firewire input :{?? (5 posts)
  • Does slow computer mean I need new motherboard??? (7 posts)
  • PCIe x16 2.0?? (5 posts)
  • TDU Problems?? (2 posts)
  • Anyone heard of MS Office Ultimate 2007 for ??!!? (5 posts)
  • Windows Defender??? (3 posts)
  • working with adobe files??? (5 posts)
  • Viewing thumbnails on a website??? (2 posts)
  • Dreamweaver or Fireworks??? (2 posts)
  • what all needs to be completed in Kingdom Hearts for there to be the music video at the end? (3 posts)
  • Air Mouse??? (3 posts)
  • Ramdac?????????? (2 posts)
  • Broadband problem with XP?? (5 posts)
  • HDMI Monitor?? (3 posts)
  •  
    Author Message

    Justkeepswimming

    Members


    Online status

    507 posts

    Location: Bermuda
    Occupation: Cab driver
    Age:

    #235942   2008-04-18 11:37 GMT      
    I figured out that !! placed anywhere in a command will replace it with the last entered command in linux (using bash). But I couldn't copy it to a file or a variable. Please help.
    Thanks Ruan, But redirecting the last used command works only in the prompt and not in a shell script. The !! is replaced by the previous command only at the command prompt. Any suggestions?

    PunkRocker

    Members


    Online status

    508 posts

    Location: Solomon Islands
    Occupation: General
    Age:

    #235943   2008-04-18 12:26 GMT      
    use echo to print
    echo !!

    use redirection to dump to file
    echo !! > last_command.txt

    use two greater-thans to append a file
    echo !! >> command_list.txt

    copying to an environment variable depends on your shell. in csh, it'd be
    setenv MYCOMMAND !!

    but in bash it'd be something like
    export MYCOMMAND=!!
    > 1 <