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 [EMAIL PROTECTED]
Re: HOWTO remove a previous wildcard file list?
on Sun, Apr 22, 2001 at 11:26:36PM -0400, Walt Mankowski ([EMAIL PROTECTED]) wrote: On Sun, Apr 22, 2001 at 11:09:23PM -0400, Mark Hurley wrote: Thank you Walt! You're welcome. :-) I can't believe I didn't find that! In case anyone else wants to view more info on history expansion with bash... http://www.kashpureff.org/nic/linux/texinfo/bash_6.html or more simply man bash Doh! ;) Well, it's not the easiest thing in the world to find on the bash man page. I first learned about this trick in the O'Reilly book Unix Power Tools. Even knowing that it's possible, I always forget the sequence and end up hunting through the man page for several minutes before I find it again. Jerry Peek is a living god. I've seen his shell presentation through SVLUG, and after fourteen years of Unix use (including a good six years of solid GNU/Linux and Unix), I picked up some tips. An alternative solution using history: $ ls A*.pdf $ ^ls^rm Larry's homepage includes links to several presentations with some good shell tips. http://www.jpeek.com/ Cheers. -- Karsten M. Self kmself@ix.netcom.comhttp://kmself.home.netcom.com/ What part of Gestalt don't you understand? There is no K5 cabal http://gestalt-system.sourceforge.net/ http://www.kuro5hin.org pgp8xNAQGR9Fh.pgp Description: PGP signature
Re: HOWTO remove a previous wildcard file list?
Mark Hurley [EMAIL PROTECTED] wrote: Anyone know of a method to easily solve this ... 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? You can repeat the last argument of the previous command using Meta-. (on some terminals Alt-. works to type that, although Escape-. works pretty much everywhere). -- Colin Watson [EMAIL PROTECTED]
Re: HOWTO remove a previous wildcard file list?
On Sun, Apr 22, 2001 at 10:15:40PM -0400, Mark Hurley wrote: Anyone know of a method to easily solve this ... 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. I would either do $ ^ls^rm or $ rm !!:$ or $ rm alt-. Pressing alt-. repeatedly cycles through the last word in each command in your history. Rob -- In case of atomic attack, the federal ruling against prayer in schools will be temporarily canceled.
Re: HOWTO remove a previous wildcard file list?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sun, 22 Apr 2001, Mark Hurley wrote: Anyone know of a method to easily solve this ... 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. !!:s/ls/rm/ !! repeat previous command s/ls/rm/ find ls in the pipe and replace it with rm You can do this in any POSIX shell. I'm thinking something like the bash CTRL-R combo? Where you would type rm (second command) and do a key-combo and fill rest of previous line in, or to step it further you could keep scrolling back in history with uparrow-something combo? 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). Thanks! Mark - -- Be Careful! I have a black belt in sna-fu! Who is John Galt? [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: PGP for Personal Privacy 5.0 Charset: noconv iQA/AwUBOuTLaR9mehuYcOjMEQKK4wCgqeBMwgkePrYDERFqCiHjjzL2pycAoJVe eJDnS2g2VEjJq9ag8b1fnNAe =pXRI -END PGP SIGNATURE-
Re: HOWTO remove a previous wildcard file list?
On Sun, Apr 22, 2001 at 10:15:40PM -0400, Mark Hurley wrote: Anyone know of a method to easily solve this ... 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. I'm thinking something like the bash CTRL-R combo? Where you would type rm (second command) and do a key-combo and fill rest of previous line in, or to step it further you could keep scrolling back in history with uparrow-something combo? Assuming you're running bash, you probably want to use !* : ls A*.pdf rm !* Walt pgpuAZQ9NmAre.pgp Description: PGP signature
Re: HOWTO remove a previous wildcard file list?
On Sun, Apr 22, 2001 at 10:32:33PM -0400, Walt Mankowski wrote: Assuming you're running bash, you probably want to use !* : ls A*.pdf rm !* Thank you Walt! I can't believe I didn't find that! In case anyone else wants to view more info on history expansion with bash... http://www.kashpureff.org/nic/linux/texinfo/bash_6.html or more simply man bash Doh! ;) Mark
Re: HOWTO remove a previous wildcard file list?
On Sun, Apr 22, 2001 at 11:09:23PM -0400, Mark Hurley wrote: Thank you Walt! You're welcome. :-) I can't believe I didn't find that! In case anyone else wants to view more info on history expansion with bash... http://www.kashpureff.org/nic/linux/texinfo/bash_6.html or more simply man bash Doh! ;) Well, it's not the easiest thing in the world to find on the bash man page. I first learned about this trick in the O'Reilly book Unix Power Tools. Even knowing that it's possible, I always forget the sequence and end up hunting through the man page for several minutes before I find it again. Walt pgp3E6NUtU5cR.pgp Description: PGP signature