[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: HOWTO remove a previous wildcard file list?



On Mon, Apr 23, 2001 at 06:40:01PM -0600, John Galt wrote:
> On Sun, 22 Apr 2001, Mark Hurley wrote:
> >I *sometimes* list the files before deleting them:
> >
> >	ls A*.pdf
> >
> >Ensuring I have only listed the ones I wish to delete, I then enter:
> >
> >	rm A*.pdf
> >
> >Great, but anyone know of an easier why than the following?
> >
> >1) Type the second command followed by the selected mask?
> >2) Go back one in bash "history", [home] to beginning of line replace
> >"ls" with "rm".
> Take a look at the manpage for bash for a bit more explanation, the tcsh
> manpage for a better one (IMHO).  Basically, if you know the number of the
> line in the history buffer, you can use !<number> to get to it.  !
> notation can get pretty deep really quickly.  There's !-<number> (go back
> in the history number entries), !<pattern> (find the last command in the
> history buffer matching command).

small typo

	!! -> repeat previous (most-recent) command
	!19 -> repeat command 19
	!-4 -> repeat 4th-ago command (back up 4 from current, in history)
	!?pattern? -> repeat most recent command containing pattern

you can also suffix any of these with

	:p

meaning print only, don't actually execute the command. so it'll
display what the command WOULD be, if you're nervious about just
going ahead on faith. :)

	!!:p
	!?find?:p

also, to get just one argument from any command, try:

	!$ -> last argument, previous command
	!-3:1 -> first argument, three commands ago
	!?grep?:* -> all arguments, from the most recent command containing 'grep'
	!:0 -> argument zero of the previous command ( == command itself)

so see if you can determine what this does:

	which update-alternatives
	ls -lF `!!`
	wc !$

-- 
DEBIAN NEWBIE TIP:
How do you determine which network services are open (active)?
Try "nmap localhost" or "nmap <your-network-ip-address>". If you
don't have "nmap" try "apt-get install nmap". NOTE: this will
scan a host for open ports -- it's poor manners to scan anybody
without their knowledge or consent. (Some folks have made it
illegal, I think, so watch out!)
...from will@serensoft.com



Reply to: