Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6099837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:19:08+00:00 2026-05-23T13:19:08+00:00

In bash, I know of 3 args from previous command shortcuts. They are: !^

  • 0

In bash, I know of 3 “args from previous command” shortcuts. They are:

  1. !^ → first arg, spaces preserved;
  2. $_ → last arg, spaces not preserved;
  3. !* → all args, spaces preserved;

So are there any more arg vars/shortcuts like that? 🙂


the $_ is useful when I call a file with one command, that’s say in a different [long named] directory, then want to call it again in my next command [i.e. $ stat a\ b\ c/sub/folder/example.txt; mv $_ . ], except when there are spaces in it, it does not work.

Why doesn’t $_ preserve spaces? To see what I mean type this:

$ echo "1" "One String Quoted"; for i in $_; do echo \"$i\"; done
and compare with

$ echo 1 2 "3 4 5"; then press enter then: $ for i in !*; do echo \"$i\" done;

Can you also explain why you have to press enter ^ then do the “for” loop in order for !* to work? [And why the $_ works without having to press enter (AKA, you can use “;” to combine the commands)]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:19:08+00:00Added an answer on May 23, 2026 at 1:19 pm

    $ does variable expansion while ! is history expansion. For ! to access the arguments you must have added the command to the bash history, which happens on execution / when pressing enter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that $ ^previous^replacement^ will substitute previous with replacement in the last command
Does anyone know of a good Command Prompt replacement? I've tried bash/Cygwin, but that
In bash, calling foo would display any output from that command on the stdout.
I want to know if there is a built-in BASH command that prints some
I know how one can execute MySQL queries / commands from bash: mysql -u[user]
I'm seeing this error when I run: rake/gem from my Git Bash. Anyone know
Does anyone know how I can read the first two characters from a file,
Does anyone know of a way to read in terminal output from bash commands
I have a bash file to download a file but i do not know
I am interested into getting into bash scripting and would like to know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.