image
Reuse Arguments
Start course
Difficulty
Beginner
Duration
7h 28m
Students
388
Ratings
3.5/5
Description

In this course, you will learn how to install a Linux system and connect to it, whether that be on Mac or Windows.

Transcript

If you want to reuse all of the arguments from your previous command, and the current command use exclamation mark, asterisk or bang star. All the arguments from the previous command is everything on the command line except for the very first thing that appeared there. So typically, you'll have a command followed by one or more arguments. And bang star takes all those arguments from the previous command, and inserts them into your current command line. I find this helpful when I'm working on a series or a list of items like files or directories or that kind of thing. It's also helpful for correcting command typos. Sometimes, I mistype the word grep. I usually spell a GRPE for some reason so this saves me some typing as I can just retype the word grep and then follow that with bang star.

Let's look at a couple of examples here. I want to create three files. And if we want to look at those files with ls, so we can use this bang star. And then, we can even say, edit those files. This is file 1. This is file 2. This is file 3. And let's even just cat them all. And then, when we're done with the files, maybe want to move them somewhere so, bang star, tmp. And you can see that those ended up in tmp. So using exclamation mark star, really saved us a lot of typing in this simple example.

Here's another example. Let's just create three directories and then, let's change the permission on those directories. And then, if we look at that, we can see that, that happened and that saved us a little bit of typing. Let's do another example here. GRPE is not a command, so, let me correct that by typing GREP, and exclamation mark, dollar sign. We can use one of our other tricks since I didn't use sudu. I can use sudu, bang bang to get the entire previous line.

About the Author
Students
43997
Labs
168
Courses
1751
Learning Paths
45

A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.